| 1 |
/** @odoo-module */ |
| 2 |
|
| 3 |
import { after, destroy, getFixture } from "@odoo/hoot"; |
| 4 |
import { App, Component, xml } from "@odoo/owl"; |
| 5 |
|
| 6 |
//----------------------------------------------------------------------------- |
| 7 |
// Exports |
| 8 |
//----------------------------------------------------------------------------- |
| 9 |
|
| 10 |
/** |
| 11 |
* @param {import("@odoo/owl").ComponentConstructor} ComponentClass |
| 12 |
* @param {ConstructorParameters<typeof App>[1]} [config] |
| 13 |
*/ |
| 14 |
export async function mountForTest(ComponentClass, config) { |
| 15 |
if (typeof ComponentClass === "string") { |
| 16 |
ComponentClass = class extends Component { |
| 17 |
static name = "anonymous component"; |
| 18 |
static props = {}; |
| 19 |
static template = xml`${ComponentClass}`; |
| 20 |
}; |
| 21 |
} |
| 22 |
|
| 23 |
const app = new App(ComponentClass, { |
| 24 |
name: "TEST", |
| 25 |
test: true, |
| 26 |
warnIfNoStaticProps: true, |
| 27 |
...config, |
| 28 |
}); |
| 29 |
const fixture = getFixture(); |
| 30 |
|
| 31 |
after(() => destroy(app)); |
| 32 |
|
| 33 |
fixture.style.backgroundColor = "#fff"; |
| 34 |
await app.mount(fixture); |
| 35 |
if (fixture.hasIframes) { |
| 36 |
await fixture.waitForIframes(); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* @param {string} url |
| 42 |
*/ |
| 43 |
export function parseUrl(url) { |
| 44 |
return url.replace(/^.*hoot\/tests/, "@hoot").replace(/(\.test)?\.js$/, ""); |
| 45 |
} |