safer test on copy_object

This commit is contained in:
Timo Hocker 2020-06-29 11:30:16 +02:00
parent c5aef0a81e
commit d8ee6074fa
2 changed files with 10 additions and 3 deletions

View File

@ -33,5 +33,8 @@
"LICENSE", "LICENSE",
"index.js", "index.js",
"index.d.ts" "index.d.ts"
] ],
"engines": {
"node": ">=10"
}
} }

View File

@ -34,11 +34,15 @@ test ('try_parse_json should fail', (t) => {
}); });
test ('copy object', (t) => { test ('copy object', (t) => {
const obj = { foo: 'bar' }; const obj = { foo: 'bar', bar: { foo: 'baz' } };
const copy = util.copy_object (obj); const copy = util.copy_object (obj);
t.deepEqual (obj, copy);
copy.foo = 'baz'; copy.foo = 'baz';
copy.bar.foo = 'bar';
t.is (copy.foo, 'baz'); t.is (copy.foo, 'baz');
t.is (copy.bar.foo, 'bar');
t.is (obj.foo, 'bar'); t.is (obj.foo, 'bar');
t.is (obj.bar.foo, 'baz');
}); });
test ('run regex', (t) => { test ('run regex', (t) => {