fix(deepClone): Fixed problems with array values

Would previously create an object with indices as keys. Now properly clones as array.

#658
This commit is contained in:
oh
2018-05-09 20:01:55 +01:00
parent 43d1cf6b75
commit f2abd5c226
3 changed files with 27 additions and 5 deletions

View File

@ -7,8 +7,12 @@ test('Testing deepClone', (t) => {
t.true(typeof deepClone === 'function', 'deepClone is a Function');
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
const b = deepClone(a);
const c = [{foo: 'bar'}];
const d = deepClone(c);
t.notEqual(a, b, 'Shallow cloning works');
t.notEqual(a.obj, b.obj, 'Deep cloning works');
t.notEqual(c, d, 'Array shallow cloning works');
t.notEqual(c[0], d[0], 'Array deep cloning works');
//t.deepEqual(deepClone(args..), 'Expected');
//t.equal(deepClone(args..), 'Expected');
//t.false(deepClone(args..), 'Expected');