[REF] qweb, component: small code refactoring

This commit is contained in:
Géry Debongnie
2019-05-02 09:47:33 +02:00
parent 9df6c0aede
commit 6350d9598d
4 changed files with 95 additions and 91 deletions
+3 -3
View File
@@ -1088,7 +1088,7 @@ describe("composition", () => {
</div>
`)
);
expect(env.qweb.templates.parent.toString()).toMatchSnapshot();
expect(env.qweb.templates.parent.fn.toString()).toMatchSnapshot();
});
test("sub widgets between t-ifs", async () => {
@@ -1358,7 +1358,7 @@ describe("random stuff/miscellaneous", () => {
const widget = new Parent(env);
await widget.mount(fixture);
expect(env.qweb.templates.parent.toString()).toMatchSnapshot();
expect(env.qweb.templates.parent.fn.toString()).toMatchSnapshot();
});
test("t-props should not be undefined (snapshotting)", async () => {
@@ -1374,7 +1374,7 @@ describe("random stuff/miscellaneous", () => {
const widget = new Parent(env);
await widget.mount(fixture);
expect(env.qweb.templates.parent.toString()).toMatchSnapshot();
expect(env.qweb.templates.parent.fn.toString()).toMatchSnapshot();
});
});
+4 -4
View File
@@ -29,7 +29,7 @@ function renderToDOM(
// we snapshot here the compiled code. This is useful to prevent unwanted code
// change.
expect(qweb.templates[template].toString()).toMatchSnapshot();
expect(qweb.templates[template].fn.toString()).toMatchSnapshot();
if (vnode.sel === undefined) {
return document.createTextNode(vnode.text!);
@@ -991,7 +991,7 @@ describe("loading templates", () => {
test("does not crash if string does not have templates", () => {
const data = "";
qweb.loadTemplates(data);
expect(qweb.processedTemplates).toEqual({});
expect(qweb.templates).toEqual({});
});
});
@@ -1104,7 +1104,7 @@ describe("debugging", () => {
`<div t-debug="1"><t t-if="true"><span t-debug="1">hey</span></t></div>`
);
qweb.render('test');
expect(qweb.templates.test.toString()).toMatchSnapshot();
expect(qweb.templates.test.fn.toString()).toMatchSnapshot();
expect(console.log).toHaveBeenCalledTimes(1);
console.log = consoleLog;
@@ -1122,7 +1122,7 @@ describe("debugging", () => {
</div>`
);
qweb.render('test');
expect(qweb.templates.test.toString()).toMatchSnapshot();
expect(qweb.templates.test.fn.toString()).toMatchSnapshot();
expect(console.log).toHaveBeenCalledWith(45);
console.log = consoleLog;