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

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-03-04 22:47:20 +01:00
import { makeTestData, makeTestEnv } from "../helpers";
import { Registry } from "../../src/ts/core/registry";
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 data = await makeTestData();
const testEnv = makeTestEnv({
...data,
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 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");
});