Make callback behavior consistent for _.clone, _.cloneDeep, _.isEqual, and _.merge and add more doc examples.

Former-commit-id: 7a53ea18e4512dfcab5649c937db0f90d7649373
This commit is contained in:
John-David Dalton
2013-01-31 00:28:47 -08:00
parent afbb2c338b
commit c3b984fea7
5 changed files with 243 additions and 169 deletions

View File

@@ -438,6 +438,11 @@
equal(actual, 'A');
});
test('_.' + methodName + ' should handle cloning if `callback` returns `undefined`', function() {
var actual = _.clone({ 'a': { 'b': 'c' } }, function() { });
deepEqual(actual, { 'a': { 'b': 'c' } });
});
});
}(1, 2, 3));
@@ -1070,8 +1075,7 @@
if (_._object) {
var object = { 'a': 1, 'b': 2, 'c': 3 };
strictEqual(_.isEqual(object, _._object), true);
}
else {
} else {
skipTest();
}
});
@@ -1106,6 +1110,11 @@
strictEqual(actual, true);
});
test('should handle comparisons if `callback` returns `undefined`', function() {
var actual = _.isEqual('a', 'a', function() { });
strictEqual(actual, true);
});
}());
/*--------------------------------------------------------------------------*/
@@ -1532,6 +1541,11 @@
deepEqual(actual, { 'a': 2 });
});
test('should handle merging if `callback` returns `undefined`', function() {
var actual = _.merge({ 'a': 1 }, { 'a': 2 }, function() { });
deepEqual(actual, { 'a': 2 });
});
}(1, 2, 3));
/*--------------------------------------------------------------------------*/