Merge branch 'master' into 13990-collection-files-service-based-on-webdav
[arvados.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: "[" + new FilterBuilder()
29                     .addEqual("groupClass", "project")
30                     .getFilters() + "]",
31                 order: undefined
32             }
33         });
34     });
35 });