mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] initial prototype of owl 2
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { TemplateSet } from "../../src/qweb/template_helpers";
|
||||
import { renderToString, TestContext, compile } from "../helpers";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// basic validation
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
describe("basic validation", () => {
|
||||
test("error if no template with given name", () => {
|
||||
const context = new TemplateSet();
|
||||
expect(() => context.getTemplate("invalidname")).toThrow("Missing template");
|
||||
});
|
||||
|
||||
test("cannot add twice the same template", () => {
|
||||
const context = new TemplateSet();
|
||||
expect(() => context.addTemplate("test", "<div/>", { allowDuplicate: true })).not.toThrow(
|
||||
"already defined"
|
||||
);
|
||||
expect(() => context.addTemplate("test", "<div/>")).toThrow("already defined");
|
||||
});
|
||||
|
||||
test("invalid xml", () => {
|
||||
const template = "<div>";
|
||||
expect(() => compile(template)).toThrow("Invalid XML in template");
|
||||
});
|
||||
|
||||
test("missing template in template set", () => {
|
||||
const context = new TestContext();
|
||||
const template = `<t t-call="othertemplate" />`;
|
||||
|
||||
context.addTemplate("template", template);
|
||||
expect(() => context.renderToString("template")).toThrowError("Missing");
|
||||
});
|
||||
|
||||
test("error when unknown directive", () => {
|
||||
const template = `<div t-best-beer="rochefort 10">test</div>`;
|
||||
expect(() => renderToString(template)).toThrow("Unknown QWeb directive: 't-best-beer'");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user