mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Ensure _.merge passes the right arguments to the callback when comparing objects. [closes #231]
Former-commit-id: 7c1ff861f753d3a2bdf62a753c94df2052d03d78
This commit is contained in:
25
test/test.js
25
test/test.js
@@ -1085,12 +1085,21 @@
|
||||
|
||||
test('lodash.' + methodName + ' should pass the correct `callback` arguments', function() {
|
||||
var args;
|
||||
|
||||
func({ 'a': 1 }, { 'a': 2 }, function() {
|
||||
args || (args = slice.call(arguments));
|
||||
});
|
||||
|
||||
deepEqual(args, [1, 2]);
|
||||
deepEqual(args, [1, 2], 'primitive property values');
|
||||
|
||||
var array = [1, 2],
|
||||
object = { 'b': 2 };
|
||||
|
||||
args = null;
|
||||
func({ 'a': array }, { 'a': object }, function() {
|
||||
args || (args = slice.call(arguments));
|
||||
});
|
||||
|
||||
deepEqual(args, [array, object], 'non-primitive property values');
|
||||
});
|
||||
|
||||
test('lodash.' + methodName + ' should correct set the `this` binding', function() {
|
||||
@@ -1884,6 +1893,18 @@
|
||||
});
|
||||
deepEqual(actual, { 'a': { 'b': [0, 1, 2] } });
|
||||
});
|
||||
|
||||
test('should pass the correct values to `callback`', function() {
|
||||
var argsList = [],
|
||||
array = [1, 2],
|
||||
object = { 'b': 2 };
|
||||
|
||||
_.merge({ 'a': array }, { 'a': object }, function(a, b) {
|
||||
argsList.push(slice.call(arguments));
|
||||
});
|
||||
|
||||
deepEqual(argsList, [[array, object], [undefined, 2]]);
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user