2019-03-14 11:23:10 +01:00
|
|
|
import { Registry } from "../../../../src/registry";
|
2019-03-07 12:15:12 +01:00
|
|
|
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 () => {
|
2019-03-07 12:15:12 +01:00
|
|
|
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 () => {
|
2019-03-07 12:15:12 +01:00
|
|
|
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");
|
|
|
|
|
});
|