[FIX] component: make sure props are validated in all cases

closes #379
This commit is contained in:
Géry Debongnie
2019-10-26 22:06:33 +02:00
committed by Aaron Bohy
parent 9779cd196c
commit 4ebe419c56
3 changed files with 26 additions and 6 deletions
+22
View File
@@ -322,6 +322,28 @@ describe("props validation", () => {
QWeb.utils.validateProps(TestWidget, { message: null });
}).toThrow();
});
test("can set default required boolean values", async () => {
class TestWidget extends Widget {
static props = ["p"];
static template = xml`<span><t t-if="props.p">hey</t></span>`;
}
class App extends Widget {
static template = xml`<div><TestWidget/></div>`;
static components = { TestWidget };
}
const w = new App(env, {});
let error;
try {
await w.mount(fixture);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.message).toBe("Missing props 'p' (component 'TestWidget')");
});
});
describe("default props", () => {