make ajax configurable

This commit is contained in:
Géry Debongnie
2019-02-06 16:17:32 +01:00
parent e2fad78eeb
commit 82d8ca9da8
3 changed files with 21 additions and 10 deletions
+5 -6
View File
@@ -1,5 +1,5 @@
import { readFile } from "fs";
import { IAjax, RPCQuery } from "../src/ts/services/ajax";
import { Ajax, RPCQuery } from "../src/ts/services/ajax";
import { WEnv } from "../src/ts/core/component";
import { Callback } from "../src/ts/core/event_bus";
import { NotificationManager } from "../src/ts/core/notifications";
@@ -30,7 +30,7 @@ export interface MockEnv extends Env {
}
export function makeTestEnv(): MockEnv {
const ajax = new MockAjax();
const ajax = new MockAjax(mockFetch);
const actionManager = new ActionManager(actionRegistry, ajax);
const router = new MockRouter();
const notifications = new NotificationManager();
@@ -49,11 +49,10 @@ export function makeTestEnv(): MockEnv {
};
}
class MockAjax implements IAjax {
async rpc(rpc: RPCQuery) {
return true;
}
function mockFetch(route: string, params: any): Promise<any> {
return Promise.resolve(true);
}
class MockAjax extends Ajax {}
class MockRouter implements IRouter {
currentQuery: Query = {};