forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone-deep.test.ts
More file actions
30 lines (25 loc) · 775 Bytes
/
Copy pathclone-deep.test.ts
File metadata and controls
30 lines (25 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { cloneDeep } from '../../src/clone-deep';
describe('cloneDeep', () => {
it('should clone null', () => {
const src = null;
expect(cloneDeep(src)).toBeNull();
});
it('should clone undefined', () => {
const src = undefined;
expect(cloneDeep(src)).toBeUndefined();
});
it('should clone an array', () => {
const src = [1, 2, 3, 4];
expect(cloneDeep(src)).toEqual(src);
});
it('should clone an object', () => {
const src = { name: 'John', age: 25 };
expect(cloneDeep(src)).toEqual(src);
});
it('should deep clone nested objects', () => {
const src = { person: { name: 'John', age: 25 } };
const cloned = cloneDeep(src);
expect(cloned).toEqual(src);
expect(cloned.person).not.toBe(src.person);
});
});