[IMP] components: re-add a bunch of components tests from owl 1

Some tests are skipped because they rely on not-yet-implemented
features.
This commit is contained in:
Samuel Degueldre
2021-10-15 13:50:55 +02:00
committed by Aaron Bohy
parent 900a3ee501
commit 9d5ffe11c7
9 changed files with 430 additions and 0 deletions
+27
View File
@@ -909,4 +909,31 @@ describe("lifecycle hooks", () => {
]);
Object.freeze(steps);
});
// TODO: rename (remove? seems covered by lifecycle semantics)
test("sub widget (inside sub node): hooks are correctly called", async () => {
let created = false;
let mounted = false;
class Child extends Component {
static template = xml`<div/>`;
setup() {
created = true;
onMounted(() => { mounted = true; })
}
}
class Parent extends Component {
static template = xml`<Child t-if="state.flag"/>`;
static components = { Child };
state = useState({ flag: false });
}
const parent = await mount(Parent, fixture);
expect(created).toBe(false);
expect(mounted).toBe(false);
parent.state.flag = true;
await nextTick();
expect(mounted).toBe(true);
expect(created).toBe(true);
});
});