add notification widget/full system

This commit is contained in:
Géry Debongnie
2019-01-29 15:19:02 +01:00
parent ec90663dd7
commit d029f87a0f
11 changed files with 149 additions and 15 deletions
+7
View File
@@ -280,6 +280,13 @@ describe("attributes", () => {
expect(result).toBe(expected);
});
test("static attributes with dashes", () => {
qweb.addTemplate("test", `<div aria-label="Close"/>`);
const result = renderToString(qweb, "test");
const expected = `<div aria-label="Close"></div>`;
expect(result).toBe(expected);
});
test("static attributes on void elements", () => {
qweb.addTemplate("test", `<img src="/test.jpg" alt="Test"/>`);
const result = renderToString(qweb, "test");
+32
View File
@@ -1,5 +1,6 @@
import { WEnv, Widget } from "../../src/ts/core/widget";
import { makeTestWEnv, makeTestFixture } from "../helpers";
import { normalize } from "../helpers";
//------------------------------------------------------------------------------
// Setup and helpers
@@ -573,6 +574,37 @@ describe("composition", () => {
"<div><div>0<button>Inc</button></div></div>"
);
});
test("sub widgets rendered in a loop", async () => {
class ChildWidget extends Widget<WEnv, { n: number }> {
name = "c";
template = `<span><t t-esc="props.n"/></span>`;
}
class Parent extends Widget<WEnv, {}> {
name = "p";
template = `
<div>
<t t-foreach="state.numbers" t-as="number">
<t t-widget="ChildWidget" t-props="{n: number}"/>
</t>
</div>`;
state = {
numbers: [1, 2, 3]
};
widgets = { ChildWidget };
}
const parent = new Parent(env);
await parent.mount(fixture);
expect(normalize(fixture.innerHTML)).toBe(
normalize(`
<div>
<span>1</span>
<span>2</span>
<span>3</span>
</div>
`)
);
});
});
describe("props evaluation (with t-props directive)", () => {
@@ -1,6 +1,6 @@
import {
NotificationManager,
Notification,
INotification,
INotificationManager
} from "../../src/ts/services/notifications";
@@ -8,7 +8,7 @@ import {
// Setup and helpers
//------------------------------------------------------------------------------
function makeNotification(notif: Partial<Notification> = {}): Notification {
function makeNotification(notif: Partial<INotification> = {}): INotification {
const defaultNotif = {
id: 1,
title: "title",