Make _.merge assign null values. [closes #151]

Former-commit-id: 5a839996db9475182d5957d2f8cb4b3c265b0d9f
This commit is contained in:
John-David Dalton
2013-01-05 00:12:33 -08:00
parent 2b23020695
commit e2c2a37221
7 changed files with 24 additions and 14 deletions

View File

@@ -622,7 +622,7 @@
(function() {
var object = Object.freeze({
'a': _.identity,
'b': null
'b': undefined
});
['non-strict', 'strict'].forEach(function(strictMode, index) {
@@ -736,7 +736,7 @@
deepEqual(lodash.defaults({}, new Foo), Foo.prototype, '_.defaults should assign inherited `source` properties: ' + basename);
deepEqual(lodash.extend({}, new Foo), Foo.prototype, '_.extend should assign inherited `source` properties: ' + basename);
actual = lodash.find(array, function(value) {
var actual = lodash.find(array, function(value) {
return 'a' in value;
});
@@ -761,7 +761,7 @@
// avoid issues comparing objects with `deepEqual`
object = { 'a': 1, 'b': 2, 'c': 3 };
var actual = lodash.omit(object, function(value) { return value == 3; });
actual = lodash.omit(object, function(value) { return value == 3; });
deepEqual(_.keys(actual).sort(), ['a', 'b', 'c'], '_.omit should not accept a `callback`: ' + basename);
actual = lodash.pick(object, function(value) { return value != 3; });

View File

@@ -1217,6 +1217,16 @@
_.reduce(array, _.merge, actual);
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3});
});
test('should assign `null` values', function() {
var actual = _.merge({ 'a': 1 }, { 'a': null });
strictEqual(actual.a, null);
});
test('should not assign `undefined` values', function() {
var actual = _.merge({ 'a': 1 }, { 'a': undefined });
equal(actual.a, 1);
});
}(1, 2, 3));
/*--------------------------------------------------------------------------*/