mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 01:32:02 +02:00
vanilla 18.0
This commit is contained in:
parent
5454004ff9
commit
d7f6d2725e
979 changed files with 428093 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
import { expect, test } from "@odoo/hoot";
|
||||
import { queryAllTexts } from "@odoo/hoot-dom";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import { Component, xml } from "@odoo/owl";
|
||||
import { getService, mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import "@web/public/public_component_service";
|
||||
|
||||
const publicComponentRegistry = registry.category("public_components");
|
||||
|
||||
test(`render Public Component`, async () => {
|
||||
class MyPublicComp extends Component {
|
||||
static template = xml`<div class="my_public_comp" t-esc="value"/>`;
|
||||
static props = ["*"];
|
||||
setup() {
|
||||
const { info } = this.props;
|
||||
this.value = typeof info === "object" ? JSON.stringify(info) : info;
|
||||
expect.step(`MyPublicComp: ${this.value} - ${typeof info}`);
|
||||
}
|
||||
}
|
||||
publicComponentRegistry.add("my_public_comp", MyPublicComp);
|
||||
|
||||
class MyComponent extends Component {
|
||||
static template = xml`
|
||||
<div>
|
||||
<owl-component name="my_public_comp" props='{"info": "blibli"}'/>
|
||||
<owl-component name="my_public_comp" props='{"info": 3}'/>
|
||||
<owl-component name="my_public_comp" props='{"info": {"test": "plop"}}'/>
|
||||
</div>
|
||||
`;
|
||||
static props = ["*"];
|
||||
}
|
||||
await mountWithCleanup(MyComponent);
|
||||
expect.verifySteps([]);
|
||||
|
||||
await getService("public_component").mountComponents();
|
||||
await animationFrame();
|
||||
expect.verifySteps([
|
||||
"MyPublicComp: blibli - string",
|
||||
"MyPublicComp: 3 - number",
|
||||
'MyPublicComp: {"test":"plop"} - object',
|
||||
]);
|
||||
|
||||
expect(`.my_public_comp`).toHaveCount(3);
|
||||
expect(queryAllTexts`.my_public_comp`).toEqual(["blibli", "3", `{"test":"plop"}`]);
|
||||
|
||||
getService("public_component").destroyComponents();
|
||||
await animationFrame();
|
||||
expect(`.my_public_comp`).toHaveCount(0);
|
||||
expect.verifySteps([]);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue