forked from lodash/lodash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdifferenceWith.test.js
More file actions
26 lines (21 loc) · 954 Bytes
/
differenceWith.test.js
File metadata and controls
26 lines (21 loc) · 954 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
import assert from 'assert';
import lodashStable from 'lodash';
import { LARGE_ARRAY_SIZE, stubOne } from './utils.js';
import differenceWith from '../differenceWith.js';
describe('differenceWith', function() {
it('should work with a `comparator`', function() {
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }],
actual = differenceWith(objects, [{ 'x': 1, 'y': 2 }], lodashStable.isEqual);
assert.deepStrictEqual(actual, [objects[1]]);
});
it('should preserve the sign of `0`', function() {
var array = [-0, 1],
largeArray = lodashStable.times(LARGE_ARRAY_SIZE, stubOne),
others = [[1], largeArray],
expected = lodashStable.map(others, lodashStable.constant(['-0']));
var actual = lodashStable.map(others, function(other) {
return lodashStable.map(differenceWith(array, other, lodashStable.eq), lodashStable.toString);
});
assert.deepStrictEqual(actual, expected);
});
});