forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (41 loc) · 1.2 KB
/
Copy pathindex.js
File metadata and controls
51 lines (41 loc) · 1.2 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
var test = require('../util/test')(__filename);
var zip = require('../../packages/array-zip');
test('zips any number of arrays together', function(t) {
t.plan(4);
var actual = zip([1, 2, 3]);
var expected = [[1], [2], [3]];
t.deepEqual(actual, expected);
actual = zip([1, 2], ['a', 'b']);
expected = [[1, 'a'], [2, 'b']];
t.deepEqual(actual, expected);
actual = zip([1, 2], ['a', 'b'], [true, false]);
expected = [[1, 'a', true], [2, 'b', false]];
t.deepEqual(actual, expected);
actual = zip([], []);
expected = [];
t.deepEqual(actual, expected);
t.end();
});
test('fill in blank spaces with undefined when given arrays of various lengths', function(t) {
t.plan(1);
var actual = zip([1, 2, 3], ['a', 'b'], [true]);
var expected = [[1, 'a', true], [2, 'b', undefined], [3, undefined, undefined]];
t.deepEqual(actual, expected);
t.end();
});
test('throws for empty / non-array arguments', function(t) {
t.plan(4);
t.throws(function() {
zip();
});
t.throws(function() {
zip(null);
});
t.throws(function() {
zip([1, 2, 3], {a: '1', b: '2', c: '3'});
});
t.throws(function() {
zip([1, 2], ['a', 'b'], undefined, {}, false, 1, 'foo');
});
t.end();
});