From 5435dd6d258382b0dc3feefe2d59c2e3f366a157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 4 Mar 2019 09:57:48 +0100 Subject: [PATCH] fix issue with test make store helper --- web/static/tests/helpers/index.ts | 2 +- web/static/tests/store/action_manager_mixin_test.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/web/static/tests/helpers/index.ts b/web/static/tests/helpers/index.ts index 46b09a8c..b75ea24e 100644 --- a/web/static/tests/helpers/index.ts +++ b/web/static/tests/helpers/index.ts @@ -35,7 +35,7 @@ export function makeTestStore(services: Partial = {}): Store { return store; } -function mockFetch(route: string, params: any): Promise { +export function mockFetch(route: string, params: any): Promise { if (route === "web/action/load") { const action = actions.find(a => a.id === params.action_id); return Promise.resolve(action); diff --git a/web/static/tests/store/action_manager_mixin_test.ts b/web/static/tests/store/action_manager_mixin_test.ts index c8cbd6c8..2b299a50 100644 --- a/web/static/tests/store/action_manager_mixin_test.ts +++ b/web/static/tests/store/action_manager_mixin_test.ts @@ -1,4 +1,4 @@ -import { makeTestStore } from "../helpers"; +import { makeTestStore, mockFetch } from "../helpers"; //------------------------------------------------------------------------------ // Tests @@ -6,14 +6,19 @@ import { makeTestStore } from "../helpers"; test("does not reload action if already done", async () => { const routes: string[] = []; - const store = makeTestStore({ rpc: async route => routes.push(route) }); + const store = makeTestStore({ + rpc: async (route, params) => { + routes.push(route); + return mockFetch(route, params); + } + }); expect(routes).toEqual([]); - store.doAction(32); + store.doAction(131); expect(routes).toEqual(["web/action/load"]); - store.doAction(32); + store.doAction(131); expect(routes).toEqual(["web/action/load"]); });