@ryupold/vode 1.8.7 → 1.8.10
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/README.md +34 -56
- package/dist/vode.cjs.min.js +2 -2
- package/dist/vode.d.ts +10 -10
- package/dist/vode.es5.min.js +7 -7
- package/dist/vode.js +97 -113
- package/dist/vode.min.js +1 -1
- package/dist/vode.min.mjs +1 -1
- package/dist/vode.mjs +97 -113
- package/dist/vode.tests.mjs +5303 -0
- package/package.json +5 -5
- package/src/state-context.ts +6 -4
- package/src/vode.ts +114 -126
- package/test/helper.ts +304 -113
- package/test/index.ts +10 -47
- package/test/mocks.ts +199 -43
- package/test/run-tests.ts +61 -0
- package/test/tests-app.ts +154 -38
- package/test/tests-catch.ts +160 -0
- package/test/tests-children.ts +31 -31
- package/test/tests-createPatch.ts +12 -12
- package/test/tests-createState.ts +11 -11
- package/test/tests-defuse.ts +35 -14
- package/test/tests-examples.ts +991 -0
- package/test/tests-hydrate.ts +59 -25
- package/test/tests-memo.ts +106 -64
- package/test/tests-mergeClass.ts +31 -31
- package/test/tests-mergeProps.ts +19 -19
- package/test/tests-mergeStyle.ts +28 -14
- package/test/tests-mount-unmount.ts +177 -154
- package/test/tests-patch-advanced.ts +86 -0
- package/test/tests-patch-merge.ts +66 -0
- package/test/tests-props.ts +15 -15
- package/test/tests-state-context.ts +56 -25
- package/test/tests-tag.ts +14 -14
- package/test/tests-vode.ts +6 -6
|
@@ -2,24 +2,24 @@ import { expect } from "./helper";
|
|
|
2
2
|
import { createState, app, DIV } from "../index";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
"createState(): throws when state is not an object": () => {
|
|
5
|
+
"createState(): throws when state is not an object": async () => {
|
|
6
6
|
const err = expect(() => createState(null as any)).toFail();
|
|
7
|
-
expect(err.message)
|
|
7
|
+
await expect(err.message)
|
|
8
8
|
.toEqual("createState() must be called with a state object");
|
|
9
9
|
},
|
|
10
10
|
|
|
11
|
-
"createState(): adds patch function to state": () => {
|
|
11
|
+
"createState(): adds patch function to state": async () => {
|
|
12
12
|
const state = createState({ x: 1 });
|
|
13
|
-
expect(typeof (state as any).patch).toEqual("function");
|
|
14
|
-
expect((state)).toEqual({ x: 1, patch: (state as any).patch });
|
|
13
|
+
await expect(typeof (state as any).patch).toEqual("function");
|
|
14
|
+
await expect((state)).toEqual({ x: 1, patch: (state as any).patch });
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
"createState(): patch is non-enumerable": () => {
|
|
17
|
+
"createState(): patch is non-enumerable": async () => {
|
|
18
18
|
const state = createState({ x: 1 });
|
|
19
|
-
expect(Object.keys(state)).toEqual(["x"]);
|
|
19
|
+
await expect(Object.keys(state)).toEqual(["x"]);
|
|
20
20
|
},
|
|
21
21
|
|
|
22
|
-
"createState(): app picks up queued patches": () => {
|
|
22
|
+
"createState(): app picks up queued patches": async () => {
|
|
23
23
|
const state: any = createState({ count: 0 });
|
|
24
24
|
state.patch({ count: 1 });
|
|
25
25
|
state.patch({ count: 2 });
|
|
@@ -28,16 +28,16 @@ export default {
|
|
|
28
28
|
root.appendChild(container);
|
|
29
29
|
app(container, state, () => [DIV]);
|
|
30
30
|
|
|
31
|
-
expect(state.count)
|
|
31
|
+
await expect(state.count)
|
|
32
32
|
.toEqual(2);
|
|
33
33
|
},
|
|
34
34
|
|
|
35
|
-
"createState(): already-patchable state is kept as-is": () => {
|
|
35
|
+
"createState(): already-patchable state is kept as-is": async () => {
|
|
36
36
|
const existingPatch = (action: any) => { };
|
|
37
37
|
const state: any = { value: 5, patch: existingPatch };
|
|
38
38
|
const result = createState(state);
|
|
39
39
|
|
|
40
|
-
expect(result.patch === existingPatch)
|
|
40
|
+
await expect(result.patch === existingPatch)
|
|
41
41
|
.toEqual(true);
|
|
42
42
|
},
|
|
43
43
|
};
|
package/test/tests-defuse.ts
CHANGED
|
@@ -9,56 +9,56 @@ export default {
|
|
|
9
9
|
.toSucceed();
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
-
"defuse(): removes _vode from container": () => {
|
|
12
|
+
"defuse(): removes _vode from container": async () => {
|
|
13
13
|
const root = document.createElement("div");
|
|
14
14
|
const container = document.createElement("div");
|
|
15
15
|
root.appendChild(container);
|
|
16
16
|
app(container, {}, () => [DIV]);
|
|
17
|
-
expect(typeof (container as any)._vode).toEqual("object");
|
|
17
|
+
await expect(typeof (container as any)._vode).toEqual("object");
|
|
18
18
|
defuse(container as any);
|
|
19
19
|
|
|
20
|
-
expect((container as any)._vode)
|
|
20
|
+
await expect((container as any)._vode)
|
|
21
21
|
.toEqual(undefined);
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
-
"defuse(): removes patch function from state": () => {
|
|
24
|
+
"defuse(): removes patch function from state": async () => {
|
|
25
25
|
const root = document.createElement("div");
|
|
26
26
|
const container = document.createElement("div");
|
|
27
27
|
root.appendChild(container);
|
|
28
28
|
const state: any = {};
|
|
29
29
|
app(container, state, () => [DIV]);
|
|
30
|
-
expect(typeof state.patch).toEqual("function");
|
|
30
|
+
await expect(typeof state.patch).toEqual("function");
|
|
31
31
|
defuse(container as any);
|
|
32
32
|
|
|
33
|
-
expect(state.patch)
|
|
33
|
+
await expect(state.patch)
|
|
34
34
|
.toEqual(undefined);
|
|
35
35
|
},
|
|
36
36
|
|
|
37
|
-
"defuse(): disables renderSync and renderAsync": () => {
|
|
37
|
+
"defuse(): disables renderSync and renderAsync": async () => {
|
|
38
38
|
const root = document.createElement("div");
|
|
39
39
|
const container = document.createElement("div");
|
|
40
40
|
root.appendChild(container);
|
|
41
41
|
app(container, {}, () => [DIV]);
|
|
42
42
|
defuse(container as any);
|
|
43
43
|
|
|
44
|
-
expect((container as any)._vode)
|
|
44
|
+
await expect((container as any)._vode)
|
|
45
45
|
.toEqual(undefined);
|
|
46
46
|
},
|
|
47
47
|
|
|
48
|
-
"defuse(): clears event listeners from rendered elements": () => {
|
|
48
|
+
"defuse(): clears event listeners from rendered elements": async () => {
|
|
49
49
|
const root = document.createElement("div");
|
|
50
50
|
const container = document.createElement("div");
|
|
51
51
|
root.appendChild(container);
|
|
52
52
|
app(container, {}, () => [DIV, { onclick: () => ({}) }] as any);
|
|
53
53
|
const node = (container as any)._vode.vode.node;
|
|
54
|
-
expect(typeof node.onclick).toEqual("function");
|
|
54
|
+
await expect(typeof node.onclick).toEqual("function");
|
|
55
55
|
defuse(container as any);
|
|
56
56
|
|
|
57
|
-
expect(node.onclick)
|
|
57
|
+
await expect(node.onclick)
|
|
58
58
|
.toEqual(null);
|
|
59
59
|
},
|
|
60
60
|
|
|
61
|
-
"defuse(): recurses into child containers": () => {
|
|
61
|
+
"defuse(): recurses into child containers": async () => {
|
|
62
62
|
const root = document.createElement("div");
|
|
63
63
|
const outer = document.createElement("div");
|
|
64
64
|
const inner = document.createElement("div");
|
|
@@ -68,7 +68,28 @@ export default {
|
|
|
68
68
|
app(inner, state, () => [DIV]);
|
|
69
69
|
defuse(outer as any);
|
|
70
70
|
|
|
71
|
-
expect(state.patch)
|
|
71
|
+
await expect(state.patch)
|
|
72
72
|
.toEqual(undefined);
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
"defuse(): clears event listeners from child vodes without _vode": async () => {
|
|
76
|
+
const root = document.createElement("div");
|
|
77
|
+
const container = document.createElement("div");
|
|
78
|
+
root.appendChild(container);
|
|
79
|
+
app(container, {}, () => [DIV, { onclick: () => ({}) },
|
|
80
|
+
[DIV, { onclick: () => ({}) }]
|
|
81
|
+
] as any);
|
|
82
|
+
const v = (container as any)._vode.vode;
|
|
83
|
+
const child1 = (v as any).node;
|
|
84
|
+
const child1onclick = child1.onclick;
|
|
85
|
+
const child2 = (v as any)[2].node;
|
|
86
|
+
await expect(typeof child1onclick).toEqual("function");
|
|
87
|
+
await expect(typeof child2.onclick).toEqual("function");
|
|
88
|
+
defuse(container as any);
|
|
89
|
+
|
|
90
|
+
await expect(child1.onclick)
|
|
91
|
+
.toEqual(null);
|
|
92
|
+
await expect(child2.onclick)
|
|
93
|
+
.toEqual(null);
|
|
94
|
+
},
|
|
74
95
|
};
|