mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 01:58:27 +00:00
test: add /util/__tests__/lib/data.test.ts
This commit is contained in:
parent
44b787ea25
commit
818ac11891
1 changed files with 47 additions and 0 deletions
47
packages/util/__tests__/lib/data.test.ts
Normal file
47
packages/util/__tests__/lib/data.test.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import {
|
||||
deepClone
|
||||
} from '../../src/lib/data';
|
||||
|
||||
|
||||
describe('@idraw/util: lib/data', () => {
|
||||
const json = {
|
||||
num: 123,
|
||||
str: 'abc',
|
||||
bool: true,
|
||||
arr: [
|
||||
{
|
||||
num: 1,
|
||||
str: 'a',
|
||||
bool: false,
|
||||
},
|
||||
{
|
||||
num: 2,
|
||||
str: 'b',
|
||||
bool: false,
|
||||
}
|
||||
],
|
||||
json: {
|
||||
num: 10,
|
||||
str: 'aaaa',
|
||||
bool: false,
|
||||
json: {
|
||||
num: 11,
|
||||
str: 'bbbb',
|
||||
bool: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const json2 = deepClone(json);
|
||||
json2.json.json.num *= 2;
|
||||
|
||||
test('deepClone', async () => {
|
||||
const result = deepClone(json);
|
||||
result.json.json.num *= 2;
|
||||
expect(result).toStrictEqual(json2);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in a new issue