[FIX] fix some issues with t-out with falsy values, and with default value

This commit is contained in:
Géry Debongnie
2022-06-28 13:21:01 +02:00
committed by aab-odoo
parent 6f86beeaf3
commit d6667ddf2e
8 changed files with 158 additions and 14 deletions
@@ -1308,6 +1308,18 @@ exports[`t-out in components can switch the contents of two t-out repeatedly 1`]
}"
`;
exports[`t-out in components t-out and updating falsy values, 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers;
return function template(ctx, node, key = \\"\\") {
return safeOutput(ctx['state'].a);
}
}"
`;
exports[`t-out in components update properly on state changes 1`] = `
"function anonymous(app, bdom, helpers
) {
+21
View File
@@ -1084,4 +1084,25 @@ describe("t-out in components", () => {
await nextTick();
expect(fixture.innerHTML).toBe("<div>1</div><div>2</div>");
});
test("t-out and updating falsy values, ", async () => {
class Test extends Component {
static template = xml`<t t-out="state.a"/>`;
state: any = useState({ a: 0 });
}
const comp = await mount(Test, fixture);
expect(fixture.innerHTML).toBe("0");
comp.state.a = undefined;
await nextTick();
expect(fixture.innerHTML).toBe("");
comp.state.a = "hello"
await nextTick();
expect(fixture.innerHTML).toBe("hello");
comp.state.a = false;
await nextTick();
expect(fixture.innerHTML).toBe("false");
});
});