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
57 lines (53 loc) · 1.26 KB
/
Copy pathindex.js
File metadata and controls
57 lines (53 loc) · 1.26 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
var test = require('../util/test')(__filename);
var intersect = require('../../packages/array-intersect');
test('intersecting arrays return intersect', function(t) {
t.plan(1);
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [3, 4, 5, 6, 7];
t.deepEqual(intersect(arr1, arr2), [3, 4, 5]);
t.end();
});
test('result is de-duped', function(t) {
t.plan(1);
var arr1 = [1, 2, 2, 4, 5];
var arr2 = [3, 2, 2, 5, 7];
t.deepEqual(intersect(arr1, arr2), [2, 5]);
t.end();
});
test('non intersecting arrays return empty array', function(t) {
t.plan(1);
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];
t.deepEqual(intersect(arr1, arr2), []);
t.end();
});
test("throws if first two arguments aren't arrays", function(t) {
t.plan(8);
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];
t.throws(function() {
intersect(undefined, arr2);
});
t.throws(function() {
intersect(null, arr2);
});
t.throws(function() {
intersect({}, arr2);
});
t.throws(function() {
intersect('a', arr2);
});
t.throws(function() {
intersect(arr1, undefined);
});
t.throws(function() {
intersect(arr1, null);
});
t.throws(function() {
intersect(arr1, {});
});
t.throws(function() {
intersect(arr1, 'a');
});
t.end();
});