1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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";
10 describe("CommonResourceService", () => {
11 const axiosInstance = axios.create();
12 const actions: ApiActions = {
13 progressFn: (id: string, working: boolean) => {},
14 errorFn: (id: string, message: string) => {}
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/", {
23 group_class: "project"
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/", {
33 filters: "[" + new FilterBuilder()
34 .addEqual("groupClass", "project")