Ensure _.merge passes the right arguments to the callback when comparing objects. [closes #231]

Former-commit-id: 7c1ff861f753d3a2bdf62a753c94df2052d03d78
This commit is contained in:
John-David Dalton
2013-04-08 21:01:57 -07:00
parent 4a11a3559d
commit ad0c287053
7 changed files with 115 additions and 91 deletions

View File

@@ -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));
/*--------------------------------------------------------------------------*/