Merge branch '18874-merge-wb2'
[arvados.git] / services / workbench2 / src / services / groups-service / groups-service.test.ts
diff --git a/services/workbench2/src/services/groups-service/groups-service.test.ts b/services/workbench2/src/services/groups-service/groups-service.test.ts
new file mode 100644 (file)
index 0000000..4e53f67
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import axios from "axios";
+import MockAdapter from "axios-mock-adapter";
+import { GroupsService } from "./groups-service";
+import { ApiActions } from "services/api/api-actions";
+
+describe("GroupsService", () => {
+
+    const axiosMock = new MockAdapter(axios);
+
+    const actions: ApiActions = {
+        progressFn: (id: string, working: boolean) => {},
+        errorFn: (id: string, message: string) => {}
+    };
+
+    beforeEach(() => {
+        axiosMock.reset();
+    });
+
+    it("#contents", async () => {
+        axiosMock
+            .onGet("/groups/1/contents")
+            .reply(200, {
+                kind: "kind",
+                offset: 2,
+                limit: 10,
+                items: [{
+                    modified_at: "now"
+                }],
+                items_available: 20
+            });
+
+        const groupsService = new GroupsService(axios, actions);
+        const resource = await groupsService.contents("1", { limit: 10, offset: 1 });
+        expect(resource).toEqual({
+            kind: "kind",
+            offset: 2,
+            limit: 10,
+            items: [{
+                modifiedAt: "now"
+            }],
+            itemsAvailable: 20
+        });
+    });
+});