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