15840: Adds comment to refactored tree construction
[arvados.git] / src / services / groups-service / groups-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 MockAdapter from "axios-mock-adapter";
7 import { GroupsService } from "./groups-service";
8 import { ApiActions } from "~/services/api/api-actions";
9
10 describe("GroupsService", () => {
11
12     const axiosMock = new MockAdapter(axios);
13
14     const actions: ApiActions = {
15         progressFn: (id: string, working: boolean) => {},
16         errorFn: (id: string, message: string) => {}
17     };
18
19     beforeEach(() => {
20         axiosMock.reset();
21     });
22
23     it("#contents", async () => {
24         axiosMock
25             .onGet("/groups/1/contents")
26             .reply(200, {
27                 kind: "kind",
28                 offset: 2,
29                 limit: 10,
30                 items: [{
31                     modified_at: "now"
32                 }],
33                 items_available: 20
34             });
35
36         const groupsService = new GroupsService(axios, actions);
37         const resource = await groupsService.contents("1", { limit: 10, offset: 1 });
38         expect(resource).toEqual({
39             kind: "kind",
40             offset: 2,
41             limit: 10,
42             items: [{
43                 modifiedAt: "now"
44             }],
45             itemsAvailable: 20
46         });
47     });
48 });