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", {
24 group_class: "project"
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", {
35 filters: "[" + new FilterBuilder()
36 .addIn("group_class", ["project", "filter"])