17319: Unit test code cleanup.
[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 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 commonService: CommonService<any>;
16
17     beforeEach(() => {
18         commonService = new CommonService<any>(axios.create(), "resource", actions);
19     });
20
21     it("throws an exception when passing uuid as empty string to get()", () => {
22         expect(() => commonService.get("")).toThrowError("UUID cannot be empty string");
23     });
24
25     it("throws an exception when passing uuid as empty string to update()", () => {
26         expect(() => commonService.update("", {})).toThrowError("UUID cannot be empty string");
27     });
28
29     it("throws an exception when passing uuid as empty string to delete()", () => {
30         expect(() => commonService.delete("")).toThrowError("UUID cannot be empty string");
31     });
32 });