Skip to content

Commit 17cc24c

Browse files
committed
update test
1 parent 1747173 commit 17cc24c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,29 @@ var diff = require('./');
1313
describe('diff', function () {
1414
it('should diff array:', function () {
1515
diff(['a', 'b', 'c'], ['b', 'c', 'e']).should.eql(['a']);
16-
diff(['foo', 'b', 'c', 'e', 'bar'], ['b', 'foo', 'e']).should.eql(['bar', 'c']);
17-
diff(['foo', 'foo'], ['a', 'b', 'c']).should.eql(['foo', 'foo']);
18-
diff(['foo'], ['a', 'b', 'c']).should.eql([]);
16+
diff(['x', 'b', 'c', 'e', 'y'], ['b', 'x', 'e']).should.eql(['c', 'y']);
17+
diff(['x', 'x'], ['a', 'b', 'c']).should.eql(['x', 'x']);
18+
diff(['x'], ['a', 'b', 'c']).should.eql(['x']);
19+
});
20+
21+
it('should include duplicates:', function () {
22+
diff(['x', 'b', 'b', 'b', 'c', 'e', 'y'], ['x', 'e']).should.eql(['b', 'b', 'b', 'c', 'y']);
23+
});
24+
25+
it('should diff elements from multiple arrays:', function () {
26+
diff(['a', 'b', 'c'], ['a'], ['b']).should.eql(['c']);
1927
});
2028

2129
it('should return an empty array if no unique elements are in the first array:', function () {
22-
diff(['foo'], ['a', 'b', 'c', 'foo']).should.eql([]);
30+
diff(['a'], ['a', 'b', 'c']).should.eql([]);
31+
});
32+
33+
it('should return the first array if the second array is empty:', function () {
34+
diff(['a', 'b', 'c'], []).should.eql(['a', 'b', 'c']);
35+
});
36+
37+
it('should return the first array if the second array is null or undefined:', function () {
38+
diff(['a', 'b', 'c'], null).should.eql(['a', 'b', 'c']);
39+
diff(['a', 'b', 'c']).should.eql(['a', 'b', 'c']);
2340
});
2441
});

0 commit comments

Comments
 (0)