1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import axios from "axios";
6 import MockAdapter from "axios-mock-adapter/types";
7 import ProjectService from "./project-service";
8 import FilterBuilder from "../../common/api/filter-builder";
9 import { ProjectResource } from "../../models/project";
11 describe("CommonResourceService", () => {
12 const axiosInstance = axios.create();
14 it(`#create has groupClass set to "project"`, async () => {
15 axiosInstance.post = jest.fn(() => Promise.resolve({ data: {} }));
16 const projectService = new ProjectService(axiosInstance);
17 const resource = await projectService.create({ name: "nameValue" });
18 expect(axiosInstance.post).toHaveBeenCalledWith("/groups/", {
20 group_class: "project"
25 it("#list has groupClass filter set by default", async () => {
26 axiosInstance.get = jest.fn(() => Promise.resolve({ data: {} }));
27 const projectService = new ProjectService(axiosInstance);
28 const resource = await projectService.list();
29 expect(axiosInstance.get).toHaveBeenCalledWith("/groups/", {
31 filters: FilterBuilder
32 .create<ProjectResource>()
33 .addEqual("groupClass", "project")