mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] qweb: make t-key directive dynamic
instead of having t-key and t-att-key. closes #36
This commit is contained in:
@@ -1056,3 +1056,29 @@ describe("whitespace handling", () => {
|
||||
expect(result3).toBe(pretagwithonlywhitespace);
|
||||
});
|
||||
});
|
||||
|
||||
describe("t-key", () => {
|
||||
test("can use t-key directive on a node", () => {
|
||||
qweb.addTemplate(
|
||||
"test",
|
||||
`<div t-key="beer.id"><t t-esc="beer.name"/></div>`
|
||||
);
|
||||
expect(
|
||||
renderToString(qweb, "test", { beer: { id: 12, name: "Chimay Rouge" } })
|
||||
).toBe("<div>Chimay Rouge</div>");
|
||||
});
|
||||
|
||||
test("t-key directive in a list", () => {
|
||||
qweb.addTemplate(
|
||||
"test",
|
||||
`<ul>
|
||||
<li t-foreach="beers" t-as="beer" t-key="beer.id"><t t-esc="beer.name"/></li>
|
||||
</ul>`
|
||||
);
|
||||
expect(
|
||||
renderToString(qweb, "test", {
|
||||
beers: [{ id: 12, name: "Chimay Rouge" }]
|
||||
})
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user