mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
5d9cff0331
Previously, we used an option to allow duplicate templates, if that option was passed, we would always replace the existing template with the new template, and if it wasn't, we would always throw an error even if the template's content was the same. Allowing to replace a template with a different one is problematic, as it may or may not have already been compiled, which may cause various problems. On the other hand, if the template is the same, there is no point in throwing an error, as we can just silently ignore the second addition.
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { renderToString, snapshotEverything, TestContext } from "../helpers";
|
|
|
|
snapshotEverything();
|
|
|
|
describe("error handling", () => {
|
|
test("invalid xml", () => {
|
|
expect(() => renderToString("<div>")).toThrow("Invalid XML in template");
|
|
});
|
|
|
|
test("nice warning if no template with given name", () => {
|
|
const context = new TestContext();
|
|
expect(() => context.renderToString("invalidname")).toThrow("Missing template");
|
|
});
|
|
|
|
test("addTemplates throw if parser error", () => {
|
|
const context = new TestContext();
|
|
expect(() => {
|
|
context.addTemplates("<templates><abc>></templates>");
|
|
}).toThrow("Invalid XML in template");
|
|
});
|
|
|
|
test("nice error when t-on is evaluated with a missing event", () => {
|
|
expect(() => renderToString(`<div t-on="somemethod"></div>`)).toThrow(
|
|
"Missing event name with t-on directive"
|
|
);
|
|
});
|
|
|
|
test("error when unknown directive", () => {
|
|
expect(() => renderToString(`<div t-best-beer="rochefort 10">test</div>`)).toThrow(
|
|
"Unknown QWeb directive: 't-best-beer'"
|
|
);
|
|
});
|
|
});
|