add test (snapshot of t-widget directive in one case)

This commit is contained in:
Géry Debongnie
2019-02-14 12:37:07 +01:00
parent 85889d6cd2
commit d9ef6d1e93
2 changed files with 71 additions and 0 deletions
+20
View File
@@ -793,6 +793,26 @@ describe("random stuff/miscellaneous", () => {
await widget.updateState({ flag: true });
expect(fixture.innerHTML).toBe("<div><span>abcdef</span></div>");
});
test("snapshotting compiled code", async () => {
env.qweb.addTemplate(
"parent",
`<div><t t-widget="child" t-props="{flag:state.flag}"/></div>`
);
class Parent extends Widget {
inlineTemplate = "parent";
widgets = { child: Child };
state = { flag: false };
}
class Child extends Widget {
inlineTemplate = `<span>abc<t t-if="props.flag">def</t></span>`;
}
const widget = new Parent(env);
await widget.mount(fixture);
expect(env.qweb.templates.parent.toString()).toMatchSnapshot();
});
});
describe("async rendering", () => {