forked from SiZapPaaiGwat/javascript-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsd.spec.js
More file actions
35 lines (30 loc) · 937 Bytes
/
msd.spec.js
File metadata and controls
35 lines (30 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var msd = require('../../src/sorting/msd.js').msd;
describe('Most-Significant Digit', function () {
'use strict';
it('should work with empty arrays', function () {
expect(msd([]).length).toBe(0);
});
it('should work with arrays with a single element', function () {
var arr = ['a'];
msd(arr);
expect(arr.length).toBe(1);
expect(arr[0]).toBe('a');
});
it('should work with arrays with equally length strings', function () {
var arr = ['bb', 'aa', 'cc'];
msd(arr);
expect(arr.length).toBe(3);
expect(arr[0]).toBe('aa');
expect(arr[1]).toBe('bb');
expect(arr[2]).toBe('cc');
});
it('should work with arrays with differently length strings', function () {
var arr = ['bb', 'aaa', 'a', 'aa'];
msd(arr);
expect(arr.length).toBe(4);
expect(arr[0]).toBe('a');
expect(arr[1]).toBe('aa');
expect(arr[2]).toBe('aaa');
expect(arr[3]).toBe('bb');
});
});