adapt tests

This commit is contained in:
Géry Debongnie
2019-02-20 09:46:22 +01:00
parent 7f3886ebba
commit 203ce91e92
16 changed files with 185 additions and 173 deletions
-1
View File
@@ -802,7 +802,6 @@ describe("random stuff/miscellaneous", () => {
}
const widget = new Test(env);
await widget.mount(fixture);
// console.log(children(widget)[0].__widget__)
expect(fixture.innerHTML).toBe("<div>txttxt<div></div></div>");
});
@@ -1,55 +0,0 @@
import { NotificationManager } from "../../src/ts/store/notifications";
test("can subscribe and add notification", () => {
let n = 0;
const notifications = new NotificationManager();
notifications.on("notification_added", null, () => n++);
notifications.on("notification_closed", null, () => n--);
expect(n).toBe(0);
const id = notifications.add({ title: "test", message: "message" });
expect(n).toBe(1);
expect(id).toBeDefined();
});
test("can close a notification", () => {
let n = 0;
const notifications = new NotificationManager();
notifications.on("notification_added", null, () => n++);
notifications.on("notification_closed", null, () => n--);
const id = notifications.add({ title: "test", message: "message" });
expect(n).toBe(1);
notifications.close(id);
expect(n).toBe(0);
});
test("notifications closes themselves after a while", () => {
jest.useFakeTimers();
let n = 0;
const notifications = new NotificationManager();
notifications.on("notification_added", null, () => n++);
notifications.on("notification_closed", null, () => n--);
notifications.add({ title: "test", message: "message" });
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(n).toBe(1);
jest.runAllTimers();
expect(n).toBe(0);
});
test("sticky notifications do not close themselves after a while", () => {
jest.useFakeTimers();
let n = 0;
const notifications = new NotificationManager();
notifications.on("notification_added", null, () => n++);
notifications.on("notification_closed", null, () => n--);
notifications.add({ title: "test", message: "message", sticky: true });
expect(setTimeout).toHaveBeenCalledTimes(0);
expect(n).toBe(1);
jest.runAllTimers();
expect(n).toBe(1);
});