mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
fix issue with test make store helper
This commit is contained in:
@@ -35,7 +35,7 @@ export function makeTestStore(services: Partial<Services> = {}): Store {
|
||||
return store;
|
||||
}
|
||||
|
||||
function mockFetch(route: string, params: any): Promise<any> {
|
||||
export function mockFetch(route: string, params: any): Promise<any> {
|
||||
if (route === "web/action/load") {
|
||||
const action = actions.find(a => a.id === params.action_id);
|
||||
return Promise.resolve(action);
|
||||
|
||||
@@ -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"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user