mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Formalize which value is picked by _.unionBy and _.unionWith to pick the result from the first array in which it occurs.
This commit is contained in:
committed by
John-David Dalton
parent
9cabc7c222
commit
9605072200
20
test/test.js
20
test/test.js
@@ -24541,6 +24541,13 @@
|
||||
|
||||
assert.deepEqual(args, [2.1]);
|
||||
});
|
||||
|
||||
QUnit.test('should output values from the first possible array', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var actual = _.unionBy([{ 'x': 1, 'y': 1 }], [{ 'x': 1, 'y': 2 }], 'x');
|
||||
assert.deepEqual(actual, [{ 'x': 1, 'y': 1 }]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -24557,6 +24564,19 @@
|
||||
|
||||
assert.deepEqual(actual, [objects[0], objects[1], others[0]]);
|
||||
});
|
||||
|
||||
QUnit.test('should output values from the first possible array', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var objects = [{ 'x': 1, 'y': 1 }],
|
||||
others = [{ 'x': 1, 'y': 2 }];
|
||||
|
||||
var actual = _.unionWith(objects, others, function(a, b) {
|
||||
return a.x == b.x;
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, [{ 'x': 1, 'y': 1 }]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user