17319: Moved mocks' initializations into beforeEach().
[arvados-workbench2.git] / src / services / common-service / common-service.test.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import axios, { AxiosInstance } from "axios";
6 import { ApiActions } from "~/services/api/api-actions";
7 import { CommonService } from "./common-service";
8
9 const actions: ApiActions = {
10     progressFn: (id: string, working: boolean) => {},
11     errorFn: (id: string, message: string) => {}
12 };
13
14 describe("CommonService", () => {
15     let axiosInstance: AxiosInstance;
16     let commonService: CommonService<any>;
17
18     beforeEach(() => {
19         commonService = new CommonService<any>(axiosInstance, "resource", actions);
20         axiosInstance = axios.create();
21     });
22
23     it("throws an exception when passing uuid as empty string to get()", () => {
24         expect(() => commonService.get("")).toThrowError("UUID cannot be empty string");
25     });
26
27     it("throws an exception when passing uuid as empty string to update()", () => {
28         expect(() => commonService.update("", {})).toThrowError("UUID cannot be empty string");
29     });
30
31     it("throws an exception when passing uuid as empty string to delete()", () => {
32         expect(() => commonService.delete("")).toThrowError("UUID cannot be empty string");
33     });
34 });