Skip to content

Commit c39b161

Browse files
committed
add test to ensure constructor is not cloned
1 parent 11e5dd5 commit c39b161

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test.js

+12
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,16 @@ describe('mergeDeep', function() {
134134
var actual = merge(fixture);
135135
assert.deepEqual(actual, fixture);
136136
});
137+
138+
it('should not clone invalid keys', function() {
139+
var obj1 = { a: { b: 1 } };
140+
var obj2 = JSON.parse('{ "a": { "c": 2 }, "constructor": { "keys": 42 } }');
141+
142+
var actual = merge({}, obj1, obj2);
143+
assert.deepEqual(actual, { a: { b: 1, c: 2 } });
144+
assert.notDeepEqual(actual.a, obj1.a);
145+
assert.notDeepEqual(actual.a, obj2.a);
146+
assert.notEqual(actual.keys, 42);
147+
assert.notEqual(actual.constructor.keys, 42);
148+
});
137149
});

0 commit comments

Comments
 (0)