forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymmetricDifferenceWith.js
25 lines (19 loc) · 1.02 KB
/
symmetricDifferenceWith.js
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
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('symmetricDifferenceWith', function() {
var Ro = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
var Ro2 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 1}, {a: 2}, {a: 3}, {a: 4}];
var So = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
var So2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}, {a: 3}, {a: 4}, {a: 5}, {a: 6}];
var eqA = function(r, s) { return r.a === s.a; };
var identical = function(a, b) { return a === b; };
it('combines two lists into the set of all elements unique to either list based on the passed-in equality predicate', function() {
eq(R.symmetricDifferenceWith(eqA, Ro, So), [{a: 1}, {a: 2}, {a: 5}, {a: 6}]);
});
it('does not allow duplicates in the output even if the input lists had duplicates', function() {
eq(R.symmetricDifferenceWith(eqA, Ro2, So2), [{a: 1}, {a: 2}, {a: 5}, {a: 6}]);
});
it('does not return a "sparse" array', function() {
eq(R.symmetricDifferenceWith(identical, [1, 3, 2, 1, 3, 1, 2, 3], [3]).length, 2);
});
});