Files
Jorge Pinna Puissant ef424a9dc2 [REF] *: remove owl from linter's accepted global variables
Before this commit, owl was in the linter's accepted global variables.
This allowed  direct access to owl global object.

For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`

Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:

`import { xml } from "@odoo/owl";`

task-id 3498859

closes odoo/odoo#137517

Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-10-05 10:21:53 +00:00

47 lines
1.6 KiB
JavaScript

/** @odoo-module */
import { loadBundle, LazyComponent } from "@web/core/assets";
import { registerCleanup } from "@web/../tests/helpers/cleanup";
import { makeTestEnv } from "@web/../tests/helpers/mock_env";
import { getFixture, patchWithCleanup } from "@web/../tests/helpers/utils";
import { Component, App, xml } from "@odoo/owl";
QUnit.module("utils", () => {
QUnit.module("Assets");
QUnit.test("LazyComponent loads the required bundle", async function (assert) {
class Test extends Component {
get childProps() {
return {
onCreated: () => assert.step("Lazy test component created"),
};
}
}
Test.template = xml`
<LazyComponent bundle="'test_assetsbundle.lazy_test_component'" Component="'LazyTestComponent'" props="childProps"/>
`;
Test.components = { LazyComponent };
const target = getFixture();
const app = new App(Test, {
test: true,
env: makeTestEnv(),
});
registerCleanup(() => app.destroy());
patchWithCleanup(loadBundle, { app });
assert.verifySteps([]);
await app.mount(target);
assert.verifySteps(["Lazy test component created"]);
assert.strictEqual(
target.innerHTML,
`<div class="o_lazy_test_component">Lazy Component!</div>`
);
assert.strictEqual(
window.getComputedStyle(target.querySelector(".o_lazy_test_component")).backgroundColor,
"rgb(165, 94, 117)",
"scss file was loaded"
);
});
});