naive implementation of mounted hook

This commit is contained in:
Géry Debongnie
2019-01-21 14:54:13 +01:00
parent fbf099f1f3
commit cd0ef90075
2 changed files with 21 additions and 3 deletions
+15
View File
@@ -91,6 +91,21 @@ describe("lifecycle hooks", () => {
await widget.mount(target);
expect(mounted).toBe(false);
});
test("mounted hook is called if mounted in DOM", async () => {
let mounted = false;
class HookWidget extends Widget {
async mounted() {
mounted = true;
}
}
const widget = makeWidget(HookWidget);
const target = document.createElement("div");
document.body.appendChild(target);
await widget.mount(target);
expect(mounted).toBe(true);
target.remove()
});
});
describe("destroy method", () => {