mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] app: add setting to warn if no static props object
This can be helpful to track components that miss a static prop description. closes #1191
This commit is contained in:
@@ -41,3 +41,17 @@ exports[`app destroy remove the widget from the DOM 1`] = `
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`app warnIfNoStaticProps works as expected 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['message'];
|
||||
return block1([txt1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
+18
-1
@@ -1,4 +1,4 @@
|
||||
import { App, Component, xml } from "../../src";
|
||||
import { App, Component, mount, xml } from "../../src";
|
||||
import { status } from "../../src/component/status";
|
||||
import { makeTestFixture, snapshotEverything, nextTick, elem } from "../helpers";
|
||||
|
||||
@@ -59,4 +59,21 @@ describe("app", () => {
|
||||
await app.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div>333</div>");
|
||||
});
|
||||
|
||||
test("warnIfNoStaticProps works as expected", async () => {
|
||||
let originalconsoleWarn = console.warn;
|
||||
let mockConsoleWarn = jest.fn(() => {});
|
||||
console.warn = mockConsoleWarn;
|
||||
|
||||
class Root extends Component {
|
||||
static template = xml`<div t-esc="message"/>`;
|
||||
}
|
||||
|
||||
await mount(Root, fixture, { dev: true, props: { messge: "hey" }, warnIfNoStaticProps: true });
|
||||
|
||||
console.warn = originalconsoleWarn;
|
||||
expect(mockConsoleWarn).toBeCalledWith(
|
||||
"Component 'Root' does not have a static props description"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user