[FIX] component: fix lifecycle order

This commit is contained in:
Géry Debongnie
2021-11-14 12:06:16 +01:00
committed by Aaron Bohy
parent 1f6e84d141
commit af80cefa76
3 changed files with 4 additions and 35 deletions
+2 -2
View File
@@ -96,10 +96,10 @@ describe("hooks", () => {
await app.mount(fixture);
app.destroy();
expect(steps).toEqual([
"hook:mounted2",
"hook:mounted1",
"hook:willUnmount1",
"hook:mounted2",
"hook:willUnmount2",
"hook:willUnmount1",
]);
});
-31
View File
@@ -939,37 +939,6 @@ describe("lifecycle hooks", () => {
expect(created).toBe(true);
});
test.skip("two different call to mounted/willunmount should work", async () => {
/*const steps: string[] = [];
function useMyHook(i) {
onMounted(() => {
steps.push("hook:mounted" + i);
});
onWillUnmount(() => {
steps.push("hook:willunmount" + i);
});
}
class MyComponent extends Component {
static template = xml`<div>hey</div>`;
constructor() {
super();
useMyHook(1);
useMyHook(2);
}
}
const component = new MyComponent();
await component.mount(fixture);
expect(fixture.innerHTML).toBe("<div>hey</div>");
component.unmount();
expect(fixture.innerHTML).toBe("");
expect(steps).toEqual([
"hook:mounted1",
"hook:mounted2",
"hook:willunmount2",
"hook:willunmount1",
]);*/
});
// TODO: rename (corresponds to https://github.com/odoo/owl/blob/master/doc/reference/concurrency_model.md#semantics)
test("component semantics", async () => {
let steps: string[] = [];