-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcombo.test.js
More file actions
63 lines (45 loc) · 1.43 KB
/
combo.test.js
File metadata and controls
63 lines (45 loc) · 1.43 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var assert = require('assert');
var combo = require('../');
suite('combo', function() {
test('1 item array', function() {
var out = combo(['a']);
assert.deepEqual(out, [['a']]);
})
test('2 item array', function() {
var out = combo(['a', 'b']);
assert.deepEqual(out, [['a'], ['b'], ['a', 'b']]);
})
test('3 item array', function() {
var out = combo(['a', 'b', 'c']);
assert.deepEqual(out, [ [ 'a' ], [ 'b' ], [ 'c' ], [ 'a', 'b' ], [ 'a', 'c' ], [ 'b', 'c' ], [ 'a', 'b', 'c' ] ]);
});
test('4 item array with min 2 and max 3 elements', function() {
var out = combo(['a', 'b', 'c', 'd'],2,3);
assert.deepEqual(out, [ [ 'a', 'b' ], [ 'a', 'c' ], [ 'a', 'd'], [ 'b', 'c' ], [ 'b', 'd'], [ 'c', 'd' ], [ 'a', 'b', 'c' ], [ 'a', 'b', 'd' ], [ 'a', 'c', 'd' ], [ 'b', 'c', 'd' ] ]);
});
test('5 item array with min 2 and max 3 elements', function() {
var out = combo(['a', 'b', 'c', 'd', 'e'],2,3);
assert.deepEqual(out, [
[ 'a', 'b' ],
[ 'a', 'c' ],
[ 'a', 'd' ],
[ 'a', 'e' ],
[ 'b', 'c' ],
[ 'b', 'd' ],
[ 'b', 'e' ],
[ 'c', 'd' ],
[ 'c', 'e' ],
[ 'd', 'e' ],
[ 'a', 'b', 'c' ],
[ 'a', 'b', 'd' ],
[ 'a', 'b', 'e' ],
[ 'a', 'c', 'd' ],
[ 'a', 'c', 'e' ],
[ 'a', 'd', 'e' ],
[ 'b', 'c', 'd' ],
[ 'b', 'c', 'e' ],
[ 'b', 'd', 'e' ],
[ 'c', 'd', 'e' ]
]);
});
});