Files
owl/web/static/tests/store/action_manager_mixin_test.ts
T
2019-03-05 15:35:29 +01:00

41 lines
1.1 KiB
TypeScript

import { makeTestData, makeTestEnv } from "../helpers";
import { Registry } from "../../src/ts/core/registry";
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
test("does not reload action if already done", async () => {
const routes: string[] = [];
const data = await makeTestData();
const testEnv = makeTestEnv({
...data,
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 data = await makeTestData();
data.actionRegistry = new Registry();
const testEnv = makeTestEnv(data);
await testEnv.store.doAction(131);
const notifs = testEnv.store.state.notifications;
expect(notifs.length).toBe(1);
expect(notifs[0].type).toBe("warning");
});