Skip to content

Commit

Permalink
add test to ensure constructor is not cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
doowb committed Jan 4, 2021
1 parent 11e5dd5 commit c39b161
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,16 @@ describe('mergeDeep', function() {
var actual = merge(fixture);
assert.deepEqual(actual, fixture);
});

it('should not clone invalid keys', function() {
var obj1 = { a: { b: 1 } };
var obj2 = JSON.parse('{ "a": { "c": 2 }, "constructor": { "keys": 42 } }');

var actual = merge({}, obj1, obj2);
assert.deepEqual(actual, { a: { b: 1, c: 2 } });
assert.notDeepEqual(actual.a, obj1.a);
assert.notDeepEqual(actual.a, obj2.a);
assert.notEqual(actual.keys, 42);
assert.notEqual(actual.constructor.keys, 42);
});
});

0 comments on commit c39b161

Please sign in to comment.