Skip to content

Commit 9c40ee6

Browse files
committed
lifecycle-snapshots
1 parent b1690f1 commit 9c40ee6

17 files changed

+3330
-2508
lines changed

tests/app/__snapshots__/app.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports[`app app: clear scheduler tasks and destroy cancelled nodes immediately
3232
}"
3333
`;
3434
35-
exports[`app app: clear scheduler tasks and destroy cancelled nodes immediately on destroy 2`] = `
35+
exports[`app app: clear scheduler tasks and destroy cancelled nodes immediately on destroy 3`] = `
3636
"function anonymous(app, bdom, helpers
3737
) {
3838
let { text, createBlock, list, multi, html, toggler, comment } = bdom;

tests/app/app.test.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useLogLifecycle,
99
makeDeferred,
1010
nextMicroTick,
11+
steps,
1112
} from "../helpers";
1213

1314
let fixture: HTMLElement;
@@ -123,23 +124,47 @@ describe("app", () => {
123124

124125
const app = new App(A);
125126
const comp = await app.mount(fixture);
126-
expect(["A:setup", "A:willStart", "A:willRender", "A:rendered", "A:mounted"]).toBeLogged();
127+
expect(steps.splice(0)).toMatchInlineSnapshot(`
128+
Array [
129+
"A:setup",
130+
"A:willStart",
131+
"A:willRender",
132+
"A:rendered",
133+
"A:mounted",
134+
]
135+
`);
127136

128137
comp.state.value = true;
129138
await nextTick();
130-
expect(["A:willRender", "B:setup", "B:willStart", "A:rendered"]).toBeLogged();
139+
expect(steps.splice(0)).toMatchInlineSnapshot(`
140+
Array [
141+
"A:willRender",
142+
"B:setup",
143+
"B:willStart",
144+
"A:rendered",
145+
]
146+
`);
131147

132148
// rerender to force the instantiation of a new B component (and cancelling the first)
133149
comp.render();
134150
await nextMicroTick();
135-
expect(["A:willRender", "B:setup", "B:willStart", "A:rendered"]).toBeLogged();
151+
expect(steps.splice(0)).toMatchInlineSnapshot(`
152+
Array [
153+
"A:willRender",
154+
"B:setup",
155+
"B:willStart",
156+
"A:rendered",
157+
]
158+
`);
136159

137160
app.destroy();
138-
expect([
139-
"A:willUnmount",
140-
"B:willDestroy",
141-
"A:willDestroy",
142-
"B:willDestroy", // make sure the 2 B instances have been destroyed synchronously
143-
]).toBeLogged();
161+
expect(steps.splice(0)).toMatchInlineSnapshot(`
162+
Array [
163+
"A:willUnmount",
164+
"B:willDestroy",
165+
"A:willDestroy",
166+
"B:willDestroy",
167+
]
168+
`);
144169
});
145170
});

tests/components/__snapshots__/concurrency.test.ts.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ exports[`changing state before first render does not trigger a render (with pare
184184
}"
185185
`;
186186

187-
exports[`changing state before first render does not trigger a render (with parent) 2`] = `
187+
exports[`changing state before first render does not trigger a render (with parent) 3`] = `
188188
"function anonymous(app, bdom, helpers
189189
) {
190190
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -254,7 +254,7 @@ exports[`components are not destroyed between animation frame 1`] = `
254254
}"
255255
`;
256256

257-
exports[`components are not destroyed between animation frame 2`] = `
257+
exports[`components are not destroyed between animation frame 3`] = `
258258
"function anonymous(app, bdom, helpers
259259
) {
260260
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -268,7 +268,7 @@ exports[`components are not destroyed between animation frame 2`] = `
268268
}"
269269
`;
270270

271-
exports[`components are not destroyed between animation frame 3`] = `
271+
exports[`components are not destroyed between animation frame 5`] = `
272272
"function anonymous(app, bdom, helpers
273273
) {
274274
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -748,7 +748,7 @@ exports[`concurrent renderings scenario 10 2`] = `
748748
}"
749749
`;
750750

751-
exports[`concurrent renderings scenario 10 3`] = `
751+
exports[`concurrent renderings scenario 10 4`] = `
752752
"function anonymous(app, bdom, helpers
753753
) {
754754
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -993,7 +993,7 @@ exports[`concurrent renderings scenario 16 3`] = `
993993
}"
994994
`;
995995

996-
exports[`concurrent renderings scenario 16 4`] = `
996+
exports[`concurrent renderings scenario 16 6`] = `
997997
"function anonymous(app, bdom, helpers
998998
) {
999999
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1024,7 +1024,7 @@ exports[`creating two async components, scenario 1 1`] = `
10241024
}"
10251025
`;
10261026

1027-
exports[`creating two async components, scenario 1 2`] = `
1027+
exports[`creating two async components, scenario 1 3`] = `
10281028
"function anonymous(app, bdom, helpers
10291029
) {
10301030
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1038,7 +1038,7 @@ exports[`creating two async components, scenario 1 2`] = `
10381038
}"
10391039
`;
10401040

1041-
exports[`creating two async components, scenario 1 3`] = `
1041+
exports[`creating two async components, scenario 1 5`] = `
10421042
"function anonymous(app, bdom, helpers
10431043
) {
10441044
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1085,7 +1085,7 @@ exports[`creating two async components, scenario 2 2`] = `
10851085
}"
10861086
`;
10871087

1088-
exports[`creating two async components, scenario 2 3`] = `
1088+
exports[`creating two async components, scenario 2 5`] = `
10891089
"function anonymous(app, bdom, helpers
10901090
) {
10911091
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1133,7 +1133,7 @@ exports[`creating two async components, scenario 3 (patching in the same frame)
11331133
}"
11341134
`;
11351135

1136-
exports[`creating two async components, scenario 3 (patching in the same frame) 3`] = `
1136+
exports[`creating two async components, scenario 3 (patching in the same frame) 5`] = `
11371137
"function anonymous(app, bdom, helpers
11381138
) {
11391139
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1308,7 +1308,7 @@ exports[`delayed render does not go through when t-component value changed 2`] =
13081308
}"
13091309
`;
13101310

1311-
exports[`delayed render does not go through when t-component value changed 3`] = `
1311+
exports[`delayed render does not go through when t-component value changed 4`] = `
13121312
"function anonymous(app, bdom, helpers
13131313
) {
13141314
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1617,7 +1617,7 @@ exports[`destroyed component causes other soon to be destroyed component to rere
16171617
}"
16181618
`;
16191619

1620-
exports[`destroyed component causes other soon to be destroyed component to rerender, weird stuff happens 2`] = `
1620+
exports[`destroyed component causes other soon to be destroyed component to rerender, weird stuff happens 3`] = `
16211621
"function anonymous(app, bdom, helpers
16221622
) {
16231623
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1628,7 +1628,7 @@ exports[`destroyed component causes other soon to be destroyed component to rere
16281628
}"
16291629
`;
16301630

1631-
exports[`destroyed component causes other soon to be destroyed component to rerender, weird stuff happens 3`] = `
1631+
exports[`destroyed component causes other soon to be destroyed component to rerender, weird stuff happens 4`] = `
16321632
"function anonymous(app, bdom, helpers
16331633
) {
16341634
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1656,7 +1656,7 @@ exports[`destroying/recreating a subcomponent, other scenario 1`] = `
16561656
}"
16571657
`;
16581658

1659-
exports[`destroying/recreating a subcomponent, other scenario 2`] = `
1659+
exports[`destroying/recreating a subcomponent, other scenario 3`] = `
16601660
"function anonymous(app, bdom, helpers
16611661
) {
16621662
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1685,7 +1685,7 @@ exports[`destroying/recreating a subwidget with different props (if start is not
16851685
}"
16861686
`;
16871687

1688-
exports[`destroying/recreating a subwidget with different props (if start is not over) 2`] = `
1688+
exports[`destroying/recreating a subwidget with different props (if start is not over) 3`] = `
16891689
"function anonymous(app, bdom, helpers
16901690
) {
16911691
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -1787,7 +1787,7 @@ exports[`rendering component again in next microtick 1`] = `
17871787
}"
17881788
`;
17891789

1790-
exports[`rendering component again in next microtick 2`] = `
1790+
exports[`rendering component again in next microtick 3`] = `
17911791
"function anonymous(app, bdom, helpers
17921792
) {
17931793
let { text, createBlock, list, multi, html, toggler, comment } = bdom;

tests/components/__snapshots__/error_handling.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ exports[`can catch errors an error in onWillDestroy, variation 1`] = `
241241
}"
242242
`;
243243

244-
exports[`can catch errors an error in onWillDestroy, variation 2`] = `
244+
exports[`can catch errors an error in onWillDestroy, variation 3`] = `
245245
"function anonymous(app, bdom, helpers
246246
) {
247247
let { text, createBlock, list, multi, html, toggler, comment } = bdom;

tests/components/__snapshots__/lifecycle.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exports[`lifecycle hooks component semantics 5`] = `
9292
}"
9393
`;
9494

95-
exports[`lifecycle hooks component semantics 6`] = `
95+
exports[`lifecycle hooks component semantics 7`] = `
9696
"function anonymous(app, bdom, helpers
9797
) {
9898
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -185,7 +185,7 @@ exports[`lifecycle hooks destroy new children before being mountged 1`] = `
185185
}"
186186
`;
187187

188-
exports[`lifecycle hooks destroy new children before being mountged 2`] = `
188+
exports[`lifecycle hooks destroy new children before being mountged 3`] = `
189189
"function anonymous(app, bdom, helpers
190190
) {
191191
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -291,7 +291,7 @@ exports[`lifecycle hooks lifecycle semantics, part 2 1`] = `
291291
}"
292292
`;
293293

294-
exports[`lifecycle hooks lifecycle semantics, part 2 2`] = `
294+
exports[`lifecycle hooks lifecycle semantics, part 2 3`] = `
295295
"function anonymous(app, bdom, helpers
296296
) {
297297
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -303,7 +303,7 @@ exports[`lifecycle hooks lifecycle semantics, part 2 2`] = `
303303
}"
304304
`;
305305

306-
exports[`lifecycle hooks lifecycle semantics, part 2 3`] = `
306+
exports[`lifecycle hooks lifecycle semantics, part 2 4`] = `
307307
"function anonymous(app, bdom, helpers
308308
) {
309309
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -348,7 +348,7 @@ exports[`lifecycle hooks lifecycle semantics, part 4 1`] = `
348348
}"
349349
`;
350350

351-
exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
351+
exports[`lifecycle hooks lifecycle semantics, part 4 3`] = `
352352
"function anonymous(app, bdom, helpers
353353
) {
354354
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
@@ -360,7 +360,7 @@ exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
360360
}"
361361
`;
362362

363-
exports[`lifecycle hooks lifecycle semantics, part 4 3`] = `
363+
exports[`lifecycle hooks lifecycle semantics, part 4 4`] = `
364364
"function anonymous(app, bdom, helpers
365365
) {
366366
let { text, createBlock, list, multi, html, toggler, comment } = bdom;

tests/components/__snapshots__/t_component.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ exports[`t-component switching dynamic component 2`] = `
180180
}"
181181
`;
182182
183-
exports[`t-component switching dynamic component 3`] = `
183+
exports[`t-component switching dynamic component 4`] = `
184184
"function anonymous(app, bdom, helpers
185185
) {
186186
let { text, createBlock, list, multi, html, toggler, comment } = bdom;

0 commit comments

Comments
 (0)