imp: better error message when evaluating/compiling templates

fixes #3
This commit is contained in:
Géry Debongnie
2019-04-02 09:55:33 +02:00
parent 56be87f26e
commit 7ebea5a486
3 changed files with 42 additions and 14 deletions
+17
View File
@@ -107,6 +107,23 @@ describe("error handling", () => {
qweb.loadTemplates("<templates><abc>></templates>");
}).toThrow("Invalid XML in template");
});
test("nice error when t-on-directive is evaluated with a missing handler", () => {
qweb.addTemplate("templatename", `<div t-on-click="somemethod"></div>`);
expect(() => qweb.render("templatename", {}, { handlers: [] })).toThrow(
"Missing handler 'somemethod' when evaluating template 'templatename'"
);
});
test("error when compiled code is invalid", () => {
qweb.addTemplate(
"templatename",
`<div t-att-hey="}/^function invalid{{>'"></div>`
);
expect(() => qweb.render("templatename")).toThrow(
"Invalid generated code while compiling template 'templatename': Unexpected token }"
);
});
});
describe("t-esc", () => {