X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c324b64f3b26e79b4640b6f0cf55671f1a261bca..75ba9a3ad91766f21d7edf9f7bfc05226b2c0144:/src/services/common-service/common-resource-service.test.ts diff --git a/src/services/common-service/common-resource-service.test.ts b/src/services/common-service/common-resource-service.test.ts index 5a3bae25fd..41a584fd78 100644 --- a/src/services/common-service/common-resource-service.test.ts +++ b/src/services/common-service/common-resource-service.test.ts @@ -32,7 +32,7 @@ describe("CommonResourceService", () => { it("#create", async () => { axiosMock - .onPost("/resource/") + .onPost("/resource") .reply(200, { owner_uuid: "ownerUuidValue" }); const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); @@ -44,7 +44,7 @@ describe("CommonResourceService", () => { axiosInstance.post = jest.fn(() => Promise.resolve({data: {}})); const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); await commonResourceService.create({ ownerUuid: "ownerUuidValue" }); - expect(axiosInstance.post).toHaveBeenCalledWith("/resource/", {owner_uuid: "ownerUuidValue"}); + expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"}); }); it("#delete", async () => { @@ -60,34 +60,52 @@ describe("CommonResourceService", () => { it("#get", async () => { axiosMock .onGet("/resource/uuid") - .reply(200, { modified_at: "now" }); + .reply(200, { + modified_at: "now", + properties: { + responsible_owner_uuid: "another_owner" + } + }); const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); const resource = await commonResourceService.get("uuid"); - expect(resource).toEqual({ modifiedAt: "now" }); + // Only first level keys are mapped to camel case + expect(resource).toEqual({ + modifiedAt: "now", + properties: { + responsible_owner_uuid: "another_owner" + } + }); }); it("#list", async () => { axiosMock - .onGet("/resource/") + .onGet("/resource") .reply(200, { kind: "kind", offset: 2, limit: 10, items: [{ - modified_at: "now" + modified_at: "now", + properties: { + is_active: true + } }], items_available: 20 }); const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); const resource = await commonResourceService.list({ limit: 10, offset: 1 }); + // First level keys are mapped to camel case inside "items" arrays expect(resource).toEqual({ kind: "kind", offset: 2, limit: 10, items: [{ - modifiedAt: "now" + modifiedAt: "now", + properties: { + is_active: true + } }], itemsAvailable: 20 });