[REF] initial prototype of owl 2

This commit is contained in:
Géry Debongnie
2020-11-26 16:45:25 +01:00
committed by Aaron Bohy
parent c06049076a
commit e746574a1d
186 changed files with 29153 additions and 33120 deletions
+51
View File
@@ -0,0 +1,51 @@
import { App, Component, mount, xml } from "../../src";
import { makeTestFixture } from "../helpers";
let fixture: HTMLElement;
beforeEach(() => {
fixture = makeTestFixture();
});
describe("env handling", () => {
test("keeps a reference to env", async () => {
const env = {};
class Test extends Component {
static template = xml`<div/>`;
}
const app = new App(Test);
app.configure({ env });
const component = await app.mount(fixture);
expect(component.env).toBe(env);
});
test("has an env by default", async () => {
class Test extends Component {
static template = xml`<div/>`;
}
const component = await mount(Test, fixture);
expect(component.env).toEqual({});
});
test("parent env is propagated to child components", async () => {
const env = {};
let child: any = null;
class Child extends Component {
static template = xml`<div/>`;
setup() {
child = this;
}
}
class Test extends Component {
static template = xml`<Child/>`;
static components = { Child };
}
const app = new App(Test);
app.configure({ env });
await app.mount(fixture);
expect(child.env).toBe(env);
});
});