X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/be8de5acc35c47d0b191223e5ece96fcf452ea5d..63ee9df0903ee7378be295d9b0656f7ae0aa3ddc:/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 2a18ce23..038c6943 100644 --- a/src/services/common-service/common-resource-service.test.ts +++ b/src/services/common-service/common-resource-service.test.ts @@ -48,6 +48,22 @@ describe("CommonResourceService", () => { expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"}); }); + it("#create ignores fields listed as readonly", async () => { + axiosInstance.post = jest.fn(() => Promise.resolve({data: {}})); + const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); + // UUID fields are read-only on all resources. + await commonResourceService.create({ uuid: "this should be ignored", ownerUuid: "ownerUuidValue" }); + expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"}); + }); + + it("#update ignores fields listed as readonly", async () => { + axiosInstance.put = jest.fn(() => Promise.resolve({data: {}})); + const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions); + // UUID fields are read-only on all resources. + await commonResourceService.update('resource-uuid', { uuid: "this should be ignored", ownerUuid: "ownerUuidValue" }); + expect(axiosInstance.put).toHaveBeenCalledWith("/resource/resource-uuid", {owner_uuid: "ownerUuidValue"}); + }); + it("#delete", async () => { axiosMock .onDelete("/resource/uuid")