Fix panel sorting
[arvados-workbench2.git] / src / common / api / common-resource-service.test.ts
index 8346624550edc4af8149ab81c0838eb02405a640..d909c092aa8bad0a37ac0308a4da8ca80a872585 100644 (file)
@@ -3,8 +3,17 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { CommonResourceService } from "./common-resource-service";
-import axios from "axios";
+import axios, { AxiosInstance } from "axios";
 import MockAdapter from "axios-mock-adapter";
+import { Resource } from "../../models/resource";
+
+export const mockResourceService = <R extends Resource, C extends CommonResourceService<R>>(Service: new (client: AxiosInstance) => C) => {
+    const axiosInstance = axios.create();
+    const axiosMock = new MockAdapter(axiosInstance);
+    const service = new Service(axiosInstance);
+    Object.keys(service).map(key => service[key] = jest.fn());
+    return service;
+};
 
 describe("CommonResourceService", () => {
     const axiosInstance = axios.create();