import { renderToString, snapshotEverything, TestContext } from "../helpers";
snapshotEverything();
describe("error handling", () => {
test("invalid xml", () => {
expect(() => renderToString("
")).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("
>");
}).toThrow("Invalid XML in template");
});
test("nice error when t-on is evaluated with a missing event", () => {
expect(() => renderToString(`
`)).toThrow(
"Missing event name with t-on directive"
);
});
test("error when unknown directive", () => {
expect(() => renderToString(`
test
`)).toThrow(
"Unknown QWeb directive: 't-best-beer'"
);
});
});