snapshot all qweb templates

This commit is contained in:
Géry Debongnie
2019-02-03 19:48:08 +01:00
parent 34475a5002
commit 150dac04d4
3 changed files with 1113 additions and 4 deletions
+1 -2
View File
@@ -224,7 +224,7 @@ export class QWeb {
throw new Error(`Template ${name} does not exist`);
}
const template = this.templates[name] || this._compile(name);
return template(context, extra);
return template.call(this, context, extra);
}
_compile(name: string): CompiledTemplate<VNode> {
@@ -261,7 +261,6 @@ export class QWeb {
}\nCompiled code:\n` + template.toString()
);
}
template = template.bind(this);
this.templates[name] = template;
return template;
}
File diff suppressed because it is too large Load Diff
+7 -2
View File
@@ -28,6 +28,11 @@ function renderToDOM(
context: EvalContext = {}
): HTMLElement | Text {
const vnode = qweb.render(template, context);
// we snapshot here the compiled code. This is useful to prevent unwanted code
// change.
expect(qweb.templates[template].toString()).toMatchSnapshot();
if (vnode.sel === undefined) {
return document.createTextNode(vnode.text!);
}
@@ -647,7 +652,7 @@ describe("t-on", () => {
});
test("can bind handlers with loop variable as argument", () => {
expect.assertions(1);
expect.assertions(2);
qweb.addTemplate(
"test",
`
@@ -664,7 +669,7 @@ describe("t-on", () => {
});
test("handler is bound to proper owner", () => {
expect.assertions(1);
expect.assertions(2);
qweb.addTemplate("test", `<button t-on-click="add">Click</button>`);
let owner = {
add() {