mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] fix some issues with t-out with falsy values, and with default value
This commit is contained in:
@@ -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
|
||||
) {
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user