forked from MrXujiang/xijs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhighFn.test.js
39 lines (36 loc) · 870 Bytes
/
highFn.test.js
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
31
32
33
34
35
36
37
38
39
import { parser } from '../src/index';
function compareObj(obj, otherObj) {
for (const key in obj) {
if (obj[key] === null) {
return otherObj[key] === null;
} else if (typeof key === 'object') {
compareObj(obj[key], otherObj[key]);
} else if (obj[key].toString() !== otherObj[key].toString()) {
return false;
}
}
return true;
}
describe('js 高级函数相关测试', () => {
test('json 超级解析器', async () => {
const obj = {
a: 1,
b: function () {},
c: {
c1: 'h5-dooring',
c2: () => {},
c3: {
c: '3fvc',
d: {
dd: () => {},
ee: /[a-z]/g,
},
},
},
d: /[0-9]/g,
e: null,
};
const copyObj = parser.parse(parser.stringify(obj));
expect(compareObj(obj, copyObj)).toBe(true);
});
});