Files
owl/web/static/tests/store/action_manager_mixin_test.ts
T
2019-03-07 17:01:02 +01:00

47 lines
1.3 KiB
TypeScript

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