17319: Moved mocks' initializations into beforeEach().
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 22 Feb 2021 19:59:40 +0000 (16:59 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 22 Feb 2021 20:00:15 +0000 (17:00 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/common-service/common-service.test.ts

index db36570a89683a6bf6d56958b25dfe77a3969938..6754710534ca247a7048b914d8e717671e8b1c12 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import axios from "axios";
+import axios, { AxiosInstance } from "axios";
 import { ApiActions } from "~/services/api/api-actions";
 import { CommonService } from "./common-service";
 
 import { ApiActions } from "~/services/api/api-actions";
 import { CommonService } from "./common-service";
 
@@ -12,9 +12,13 @@ const actions: ApiActions = {
 };
 
 describe("CommonService", () => {
 };
 
 describe("CommonService", () => {
-    const axiosInstance = axios.create();
-    // const axiosMock = new MockAdapter(axiosInstance);
-    const commonService = new CommonService(axiosInstance, "resource", actions);
+    let axiosInstance: AxiosInstance;
+    let commonService: CommonService<any>;
+
+    beforeEach(() => {
+        commonService = new CommonService<any>(axiosInstance, "resource", actions);
+        axiosInstance = axios.create();
+    });
 
     it("throws an exception when passing uuid as empty string to get()", () => {
         expect(() => commonService.get("")).toThrowError("UUID cannot be empty string");
 
     it("throws an exception when passing uuid as empty string to get()", () => {
         expect(() => commonService.get("")).toThrowError("UUID cannot be empty string");