17426: Add "enableWhenPristine" option for dialog boxes.
[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 "~/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             name: "nameValue",
23             group_class: "project"
24         });
25     });
26
27     it("#list has groupClass filter set by default", async () => {
28         axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
29         const projectService = new ProjectService(axiosInstance, actions);
30         const resource = await projectService.list();
31         expect(axiosInstance.get).toHaveBeenCalledWith("/groups", {
32             params: {
33                 filters: "[" + new FilterBuilder()
34                     .addEqual("group_class", "project")
35                     .getFilters() + "]",
36                 order: undefined
37             }
38         });
39     });
40 });