forked from mgechev/javascript-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsd.spec.js
More file actions
34 lines (29 loc) · 906 Bytes
/
lsd.spec.js
File metadata and controls
34 lines (29 loc) · 906 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
var lsd = require('../../src/sorting/lsd.js').lsd;
describe('Least-Significant Digit', function () {
'use strict';
it('should work with empty arrays', function () {
expect(lsd([]).length).toBe(0);
});
it('should work with arrays with a single element', function () {
var arr = ['a'];
lsd(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'];
lsd(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 equally length strings', function () {
var arr = ['bbb', 'aac', 'aaa'];
lsd(arr, 3);
expect(arr.length).toBe(3);
expect(arr[0]).toBe('aaa');
expect(arr[1]).toBe('aac');
expect(arr[2]).toBe('bbb');
});
});