@cloudpss/yaml 0.6.0-alpha.8 → 0.6.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tests/map.ts +18 -26
- package/tests/types.ts +6 -8
package/package.json
CHANGED
package/tests/map.ts
CHANGED
|
@@ -5,13 +5,11 @@ describe(`can load map`, () => {
|
|
|
5
5
|
const map = load(`!!js/map [['a', 1], ['b', { c: 2 }], [{ d: 3 }, 'e']]`);
|
|
6
6
|
expect(map).toBeInstanceOf(Map);
|
|
7
7
|
expect(map).toEqual(
|
|
8
|
-
new Map(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
]),
|
|
14
|
-
),
|
|
8
|
+
new Map<unknown, unknown>([
|
|
9
|
+
['a', 1],
|
|
10
|
+
['b', { c: 2 }],
|
|
11
|
+
[{ d: 3 }, 'e'],
|
|
12
|
+
]),
|
|
15
13
|
);
|
|
16
14
|
});
|
|
17
15
|
it(`from null`, () => {
|
|
@@ -23,36 +21,30 @@ describe(`can load map`, () => {
|
|
|
23
21
|
const map = load(`!!js/map [['a', 1], ['b', { c: 2 }], ['a', 1]]`);
|
|
24
22
|
expect(map).toBeInstanceOf(Map);
|
|
25
23
|
expect(map).toEqual(
|
|
26
|
-
new Map(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]),
|
|
31
|
-
),
|
|
24
|
+
new Map<unknown, unknown>([
|
|
25
|
+
['a', 1],
|
|
26
|
+
['b', { c: 2 }],
|
|
27
|
+
]),
|
|
32
28
|
);
|
|
33
29
|
});
|
|
34
30
|
it(`with duplicate objects`, () => {
|
|
35
31
|
const map = load(`!!js/map [[{ a: 1 }, 'b'], [{ a: 1 }, 'c']]`);
|
|
36
32
|
expect(map).toBeInstanceOf(Map);
|
|
37
33
|
expect(map).toEqual(
|
|
38
|
-
new Map(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
]),
|
|
43
|
-
),
|
|
34
|
+
new Map([
|
|
35
|
+
[{ a: 1 }, 'b'],
|
|
36
|
+
[{ a: 1 }, 'c'],
|
|
37
|
+
]),
|
|
44
38
|
);
|
|
45
39
|
});
|
|
46
40
|
});
|
|
47
41
|
|
|
48
42
|
it(`can dump map`, () => {
|
|
49
|
-
const map = new Map(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]),
|
|
55
|
-
);
|
|
43
|
+
const map = new Map<unknown, unknown>([
|
|
44
|
+
['a', 1],
|
|
45
|
+
['b', { c: 2 }],
|
|
46
|
+
[{ d: 3 }, 'e'],
|
|
47
|
+
]);
|
|
56
48
|
const dumped = dump(map);
|
|
57
49
|
expect(dumped).toMatchSnapshot();
|
|
58
50
|
expect(load(dumped)).toEqual(map);
|
package/tests/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ it('ArrayBuffer should be dumped as base64', () => {
|
|
|
16
16
|
const data = new Uint8Array([63, 43, 213, 117, 49, 122, 160, 215]);
|
|
17
17
|
const dumped = dump(data.buffer);
|
|
18
18
|
expect(dumped).toMatchSnapshot();
|
|
19
|
-
expect(new Uint8Array(
|
|
19
|
+
expect(new Uint8Array(load(dumped) as ArrayBuffer)).toEqual(data);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('Empty arrayBuffer should be dumped as base64', () => {
|
|
@@ -90,13 +90,11 @@ describe('TypedArray should be dumped as array', () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('map should be dumped as pair sequence', () => {
|
|
93
|
-
const data = new Map(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
]),
|
|
99
|
-
);
|
|
93
|
+
const data = new Map<unknown, unknown>([
|
|
94
|
+
['a', 1],
|
|
95
|
+
['b', { c: 2 }],
|
|
96
|
+
[{ d: 3 }, 'e'],
|
|
97
|
+
]);
|
|
100
98
|
const dumped = dump(data);
|
|
101
99
|
expect(dumped).toMatchSnapshot();
|
|
102
100
|
expect(load(dumped)).toEqual(data);
|