diff --git a/tests/client.test.ts b/tests/client.test.ts index a16aa0b..390b699 100644 --- a/tests/client.test.ts +++ b/tests/client.test.ts @@ -364,6 +364,27 @@ describe("OpenFGA Client", () => { expect(scope1.isDone()).toBe(true); } }); + + it("should properly call the OpenFga Write API when providing one empty array", async () => { + const tuple = { + user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", + relation: "admin", + object: "workspace:1", + }; + const scope = nocks.write(baseConfig.storeId!); + + expect(scope.isDone()).toBe(false); + const data = await fgaClient.write({ + writes: [tuple], + deletes: [] + }, { + authorizationModelId: "01GXSA8YR785C4FYS3C0RTG7B1", + }); + + expect(scope.isDone()).toBe(true); + expect(data.writes.length).toBe(1); + expect(data.deletes.length).toBe(0); + }); }); describe("WriteTuples", () => {