18128: Improves collection's view different panels layout.
[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 "services/api/filter-builder";
8 import { ApiActions } from "services/api/api-actions";
9
10 describe("CommonResourceService", () => {
11     const axiosInstance = axios.create();
12     const actions: ApiActions = {
13         progressFn: (id: string, working: boolean) => {},
14         errorFn: (id: string, message: string) => {}
15     };
16
17     it(`#create has groupClass set to "project"`, async () => {
18         axiosInstance.post = jest.fn(() => Promise.resolve({ data: {} }));
19         const projectService = new ProjectService(axiosInstance, actions);
20         const resource = await projectService.create({ name: "nameValue" });
21         expect(axiosInstance.post).toHaveBeenCalledWith("/groups", {
22             group: {
23                 name: "nameValue",
24                 group_class: "project"
25             }
26         });
27     });
28
29     it("#list has groupClass filter set by default", async () => {
30         axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
31         const projectService = new ProjectService(axiosInstance, actions);
32         const resource = await projectService.list();
33         expect(axiosInstance.get).toHaveBeenCalledWith("/groups", {
34             params: {
35                 filters: "[" + new FilterBuilder()
36                     .addIn("group_class", ["project", "filter"])
37                     .getFilters() + "]",
38                 order: undefined
39             }
40         });
41     });
42 });