Files
owl/demo/static/tests/store/action_manager_mixin_test.ts
T

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-03-04 22:47:20 +01:00
import { Registry } from "../../src/ts/core/registry";
import { makeTestEnv } from "../helpers";
2019-03-01 11:26:00 +01:00
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("does not reload action if already done", async () => {
const routes: string[] = [];
2019-03-04 22:47:20 +01:00
const testEnv = makeTestEnv({
mockRPC(route, params) {
2019-03-04 09:57:48 +01:00
routes.push(route);
2019-03-04 22:47:20 +01:00
return this.rpc(route, params);
2019-03-04 09:57:48 +01:00
}
});
2019-03-04 22:47:20 +01:00
2019-03-01 11:26:00 +01:00
expect(routes).toEqual([]);
2019-03-04 22:47:20 +01:00
testEnv.store.doAction(131);
2019-03-01 11:26:00 +01:00
expect(routes).toEqual(["web/action/load"]);
2019-03-04 22:47:20 +01:00
testEnv.store.doAction(131);
2019-03-01 11:26:00 +01:00
expect(routes).toEqual(["web/action/load"]);
});
2019-03-04 22:47:20 +01:00
test("display a warning if client action is not in registry", async () => {
const testEnv = makeTestEnv({ actionRegistry: new Registry() });
2019-03-04 22:47:20 +01:00
await testEnv.store.doAction(131);
const notifs = testEnv.store.state.notifications;
expect(notifs.length).toBe(1);
expect(notifs[0].type).toBe("warning");
});
2019-03-06 17:36:22 +01:00
test("display a warning if view is not in registry", async () => {
const testEnv = makeTestEnv({ viewRegistry: new Registry() });
2019-03-06 17:36:22 +01:00
await testEnv.store.doAction(250);
const notifs = testEnv.store.state.notifications;
expect(notifs.length).toBe(1);
expect(notifs[0].type).toBe("warning");
});