[FIX] re-introduce some missing tests

The point is to have visibility on the development of the owl2 features.
This commit reintroduces some tests keeping them skipped in order to fulfill that purpose.

There still are some missing tests though.
This commit is contained in:
Lucas Perais (lpe)
2021-10-15 10:58:29 +02:00
committed by Aaron Bohy
parent d6668e3439
commit 52fa81c510
16 changed files with 2795 additions and 55 deletions
@@ -126,6 +126,24 @@ exports[`t-if boolean value condition false else 1`] = `
}"
`;
exports[`t-if boolean value condition missing 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['condition']) {
b2 = text(\`fail\`);
}
return block1([], [b2]);
}
}"
`;
exports[`t-if can use some boolean operators in expressions 1`] = `
"function anonymous(bdom, helpers
) {
+43
View File
@@ -379,4 +379,47 @@ describe("special cases for some specific html attributes/properties", () => {
const input = fixture.querySelector("input")!;
expect(input.indeterminate).toBe(true);
});
test.skip("textarea with t-att-value", () => {
// render input with initial value
/* qweb.addTemplate("test", `<textarea t-att-value="v"/>`);
const vnode1 = qweb.render("test", { v: "zucchini" });
const vnode2 = patch(document.createElement("textarea"), vnode1);
let elm = vnode2.elm as HTMLInputElement;
expect(elm.value).toBe("zucchini");
// change value manually in textarea, to simulate user textarea
elm.value = "tomato";
expect(elm.value).toBe("tomato");
// rerender with a different value, and patch actual dom, to check that
// textarea value was properly reset by owl
const vnode3 = qweb.render("test", { v: "potato" });
patch(vnode2, vnode3);
expect(elm.value).toBe("potato");*/
});
test.skip("select with t-att-value", () => {
/* const template = `
<select t-att-value="value">
<option value="potato">Potato</option>
<option value="tomato">Tomato</option>
<option value="onion">Onion</option>
</select>`;
qweb.addTemplate("test", template);
const vnode1 = qweb.render("test", { value: "tomato" });
const vnode2 = patch(document.createElement("select"), vnode1);
let elm = vnode2.elm as HTMLSelectElement;
expect(elm.value).toBe("tomato");
elm.value = "potato";
expect(elm.value).toBe("potato");
// rerender with a different value, and patch actual dom, to check that
// select value was properly reset by owl
const vnode3 = qweb.render("test", { value: "onion" });
patch(vnode2, vnode3);
expect(elm.value).toBe("onion");
expect(qweb.templates.test.fn.toString()).toMatchSnapshot();*/
});
});
+30
View File
@@ -123,3 +123,33 @@ describe("simple templates, mostly static", () => {
expect(renderToString(template)).toBe(template);
});
});
describe("loading templates", () => {
test.skip("can initialize qweb with a string", () => {
/* const templates = `<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<div t-name="hey">jupiler</div>
</templates>`;
const qweb = new QWeb({ templates });
expect(renderToString(qweb, "hey")).toBe("<div>jupiler</div>");*/
});
test.skip("can load a few templates from a xml string", () => {
/*const data = `<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="items"><li>ok</li><li>foo</li></t>
<ul t-name="main"><t t-call="items"/></ul>
</templates>`;
qweb.addTemplates(data);
const result = renderToString(qweb, "main");
expect(result).toBe("<ul><li>ok</li><li>foo</li></ul>");*/
});
test.skip("does not crash if string does not have templates", () => {
/*const data = "";
qweb.addTemplates(data);
expect(Object.keys(qweb.templates)).toEqual([]);*/
});
});
+5
View File
@@ -16,6 +16,11 @@ describe("t-if", () => {
expect(renderToString(template, {})).toBe("<div></div>");
});
test("boolean value condition missing", () => {
const template = `<span><t t-if="condition">fail</t></span>`;
expect(renderToString(template)).toBe("<span></span>");
});
test("just a t-if", () => {
const template = `<t t-if="condition">ok</t>`;
expect(renderToString(template, { condition: true })).toBe("ok");