mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: properly handle mounting a destroyed component
part of #685
This commit is contained in:
@@ -2,6 +2,7 @@ import { Component, Env } from "../../src/component/component";
|
||||
import { useState } from "../../src/hooks";
|
||||
import { xml } from "../../src/tags";
|
||||
import { makeDeferred, makeTestEnv, makeTestFixture, nextTick, nextMicroTick } from "../helpers";
|
||||
import { scheduler } from "../../src/component/scheduler";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Setup and helpers
|
||||
@@ -490,4 +491,22 @@ describe("unmounting and remounting", () => {
|
||||
expect(steps).toEqual(["1 resolved", "2 resolved"]);
|
||||
expect(fixture.innerHTML).toBe("<div>Hey</div>");
|
||||
});
|
||||
|
||||
test("mounting a destroyed widget", async () => {
|
||||
class MyWidget extends Component {
|
||||
static template = xml`<div>Hey</div>`;
|
||||
}
|
||||
const w = new MyWidget();
|
||||
w.destroy(); // because, why not
|
||||
|
||||
let error;
|
||||
try {
|
||||
await w.mount(fixture);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
expect(scheduler.tasks.length).toBe(0);
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toBe("Cannot mount a destroyed component");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user