refs #14007 Merge branch 'origin/14007-ts-paths'
[arvados-workbench2.git] / src / services / project-service / project-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 { ProjectService } from "./project-service";
7 import { FilterBuilder } from "~/common/api/filter-builder";
8
9 describe("CommonResourceService", () => {
10     const axiosInstance = axios.create();
11
12     it(`#create has groupClass set to "project"`, async () => {
13         axiosInstance.post = jest.fn(() => Promise.resolve({ data: {} }));
14         const projectService = new ProjectService(axiosInstance);
15         const resource = await projectService.create({ name: "nameValue" });
16         expect(axiosInstance.post).toHaveBeenCalledWith("/groups/", {
17             name: "nameValue",
18             group_class: "project"
19         });
20     });
21
22     it("#list has groupClass filter set by default", async () => {
23         axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
24         const projectService = new ProjectService(axiosInstance);
25         const resource = await projectService.list();
26         expect(axiosInstance.get).toHaveBeenCalledWith("/groups/", {
27             params: {
28                 filters: FilterBuilder
29                     .create()
30                     .addEqual("groupClass", "project")
31                     .serialize()
32             }
33         });
34     });
35 });