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
+5 -1
View File
@@ -1,7 +1,7 @@
import { WEnv } from "./core/component";
import { QWeb } from "./core/qweb_vdom";
import { idGenerator } from "./core/utils";
import { Store, Services, RPC } from "./store";
import { INotification, RPC, Services, Store } from "./store";
//------------------------------------------------------------------------------
// Types
@@ -12,6 +12,8 @@ export interface Env extends WEnv {
// helpers
dispatch(action: string, param?: any): void;
addNotification(notif: Partial<INotification>): number;
closeNotification(id: number);
rpc: RPC;
// configuration
@@ -33,6 +35,8 @@ export function makeEnv(store: Store, templates: string): Env {
getID: idGenerator(),
services: store.services,
dispatch: store.dispatch.bind(store),
addNotification: store.addNotification.bind(store),
closeNotification: store.closeNotification.bind(store),
rpc: store.rpc.bind(store),
debug: false,
isMobile: window.innerWidth <= 768
+1 -1
View File
@@ -1,5 +1,5 @@
import { findInTree } from "./core/utils";
import { MenuItem, MenuInfo } from "./store";
import { MenuInfo, MenuItem } from "./store";
//------------------------------------------------------------------------------
// Templates
+5 -5
View File
@@ -152,10 +152,10 @@ export class Store extends EventBus {
this.updateState({ inHome: !this.state.inHome });
break;
case "add_notification":
this.add(params);
this.addNotification(params);
break;
case "close_notification":
this.close(params);
this.closeNotification(params);
break;
}
}
@@ -167,7 +167,7 @@ export class Store extends EventBus {
nextID = 1;
add(notif: Partial<INotification>): number {
addNotification(notif: Partial<INotification>): number {
const id = this.nextID++;
const defaultVals = {
title: "",
@@ -178,11 +178,11 @@ export class Store extends EventBus {
const notification = Object.assign(defaultVals, notif, { id });
this.trigger("notification_added", notification);
if (!notification.sticky) {
setTimeout(() => this.close(id), 2500);
setTimeout(() => this.closeNotification(id), 2500);
}
return id;
}
close(id: number) {
closeNotification(id: number) {
this.trigger("notification_closed", id);
}
+1 -1
View File
@@ -46,7 +46,7 @@ export class Discuss extends Widget<{}, State> {
addNotif(sticky: boolean) {
const text = (<any>this.refs.textinput).value;
const message = `It is now ${new Date().toLocaleTimeString()}.<br/> Msg: ${text}`;
this.env.dispatch("add_notification", {
this.env.addNotification({
title: "hey",
message: message,
sticky
+1 -1
View File
@@ -7,6 +7,6 @@ export class Notification extends Widget<INotification, {}> {
close(ev: MouseEvent) {
// we do not want the url to change
ev.preventDefault();
this.env.dispatch("close_notification", this.props.id);
this.env.closeNotification(this.props.id);
}
}