mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { Component, mount } from "../../src";
|
|
import { status } from "../../src/component/status";
|
|
import { xml } from "../../src/tags";
|
|
import { makeTestFixture, snapshotEverything } from "../helpers";
|
|
|
|
let fixture: HTMLElement;
|
|
|
|
snapshotEverything();
|
|
|
|
beforeEach(() => {
|
|
fixture = makeTestFixture();
|
|
});
|
|
|
|
describe("basics", () => {
|
|
test("no component catching error lead to full app destruction", async () => {
|
|
class ErrorComponent extends Component {
|
|
static template = xml`<div>hey<t t-esc="props.flag and state.this.will.crash"/></div>`;
|
|
}
|
|
|
|
class Parent extends Component {
|
|
static template = xml`<div><ErrorComponent flag="state.flag"/></div>`;
|
|
static components = { ErrorComponent };
|
|
state = { flag: false };
|
|
}
|
|
const parent = await mount(Parent, fixture);
|
|
expect(fixture.innerHTML).toBe("<div><div>heyfalse</div></div>");
|
|
parent.state.flag = true;
|
|
|
|
let error;
|
|
try {
|
|
await parent.render();
|
|
} catch (e) {
|
|
error = e;
|
|
}
|
|
expect(fixture.innerHTML).toBe("");
|
|
expect(status(parent)).toBe("destroyed");
|
|
expect(error).toBeDefined();
|
|
const regexp =
|
|
/Cannot read properties of undefined \(reading 'this'\)|Cannot read property 'this' of undefined/g;
|
|
expect(error.message).toMatch(regexp);
|
|
});
|
|
});
|