mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Added support for _.merge to accept callback and thisArg arguments. [closes #154]
Former-commit-id: 5d641ae4ba1d120d776a895f8bc9b8c1a7def0b6
This commit is contained in:
26
test/test.js
26
test/test.js
@@ -1402,6 +1402,32 @@
|
||||
ok(1 in actual);
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should pass the correct `callback` arguments', function() {
|
||||
var args;
|
||||
|
||||
_.merge({ 'a': 1 }, { 'a': 2 }, function() {
|
||||
args || (args = slice.call(arguments));
|
||||
});
|
||||
|
||||
deepEqual(args, [1, 2]);
|
||||
});
|
||||
|
||||
test('should correct set the `this` binding', function() {
|
||||
var actual = _.merge({}, { 'a': 0 }, function(a, b) {
|
||||
return this[b];
|
||||
}, [2]);
|
||||
|
||||
deepEqual(actual, { 'a': 2 });
|
||||
});
|
||||
|
||||
test('should work as a deep `_.defaults`', function() {
|
||||
var object = { 'a': { 'b': 1 } },
|
||||
source = { 'a': { 'b': 2, 'c': 3 } },
|
||||
expected = { 'a': { 'b': 1, 'c': 3 } };
|
||||
|
||||
deepEqual(_.merge(object, source, _.defaults), expected);
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user