This commit is contained in:
Géry Debongnie
2019-01-21 15:54:18 +01:00
parent 9be5cc1760
commit 526555fd21
+16 -16
View File
@@ -56,12 +56,14 @@ describe("basic widget properties", () => {
test("widget style and classname", async () => { test("widget style and classname", async () => {
class StyledWidget extends Widget { class StyledWidget extends Widget {
template= `<div style="font-weight:bold;" class="some-class">world</div>`; template = `<div style="font-weight:bold;" class="some-class">world</div>`;
} }
const widget = makeWidget(StyledWidget); const widget = makeWidget(StyledWidget);
const target = document.createElement("div"); const target = document.createElement("div");
await widget.mount(target); await widget.mount(target);
expect(target.innerHTML).toBe(`<div style="font-weight:bold;" class="some-class">world</div>`); expect(target.innerHTML).toBe(
`<div style="font-weight:bold;" class="some-class">world</div>`
);
}); });
}); });
@@ -104,7 +106,7 @@ describe("lifecycle hooks", () => {
document.body.appendChild(target); document.body.appendChild(target);
await widget.mount(target); await widget.mount(target);
expect(mounted).toBe(true); expect(mounted).toBe(true);
target.remove() target.remove();
}); });
}); });
@@ -120,19 +122,17 @@ describe("destroy method", () => {
}); });
describe("composition", () => { describe("composition", () => {
class WidgetA extends Widget {
class WidgetB extends Widget { name = "a";
template= `<div>world</div>`; template = `<div>Hello<t t-widget="b"/></div>`;
widgets = { b: WidgetB };
} }
class WidgetA extends Widget { class WidgetB extends Widget {
name="a"; template = `<div>world</div>`;
template= `<div>Hello<t t-widget="b"/></div>`;
widgets = {b: WidgetB}
} }
test("a widget with a sub widget", async () => { test("a widget with a sub widget", async () => {
const widget = makeWidget(WidgetA); const widget = makeWidget(WidgetA);
const target = document.createElement("div"); const target = document.createElement("div");
await widget.mount(target); await widget.mount(target);
@@ -140,11 +140,11 @@ describe("composition", () => {
}); });
test("t-refs on widget are widgets", async () => { test("t-refs on widget are widgets", async () => {
class WidgetC extends Widget { class WidgetC extends Widget {
name="a"; name = "a";
template= `<div t-debug="1">Hello<t t-ref="mywidgetb" t-widget="b"/></div>`; template = `<div t-debug="1">Hello<t t-ref="mywidgetb" t-widget="b"/></div>`;
widgets = {b: WidgetB} widgets = { b: WidgetB };
} }
const widget = makeWidget(WidgetC); const widget = makeWidget(WidgetC);
const target = document.createElement("div"); const target = document.createElement("div");
await widget.mount(target); await widget.mount(target);