Fix deepClone edge case

This commit is contained in:
Jy
2019-01-11 14:52:53 +08:00
parent a943631e27
commit 09e2709fa4
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,8 @@ const a = { foo: 'bar', obj: { a: 1, b: 2 } };
const b = deepClone(a);
const c = [{ foo: 'bar' }];
const d = deepClone(c);
const e = { edge: [] };
const f = deepClone(e);
test('Shallow cloning works', () => {
expect(a).not.toBe(b);
});
@ -20,3 +22,6 @@ test('Array shallow cloning works', () => {
test('Array deep cloning works', () => {
expect(c[0]).not.toBe(d[0]);
});
test('Array shallow cloning edge case works', () => {
expect(f.edge).toEqual([]);
});