diff --git a/test/auctions.test.ts b/test/auctions.test.ts index aca16a0..72ca2b8 100644 --- a/test/auctions.test.ts +++ b/test/auctions.test.ts @@ -18,6 +18,7 @@ describe("createAuction", () => { returnStatus(401, `${baseURL}/${apis.auctions}`); expect(createAuction({ apiKey: "apiKey" }, {} as TopsortAuction)).rejects.toEqual({ status: 401, + retry: false, statusText: "Unauthorized", body: {}, }); @@ -27,6 +28,7 @@ describe("createAuction", () => { returnStatus(429, `${baseURL}/${apis.auctions}`); expect(createAuction({ apiKey: "apiKey" }, {} as TopsortAuction)).rejects.toEqual({ status: 429, + retry: true, statusText: "Too Many Requests", body: {}, }); @@ -36,6 +38,7 @@ describe("createAuction", () => { returnStatus(500, `${baseURL}/${apis.auctions}`); expect(createAuction({ apiKey: "apiKey" }, {} as TopsortAuction)).rejects.toEqual({ status: 500, + retry: true, statusText: "Internal Server Error", body: {}, }); diff --git a/test/events.test.ts b/test/events.test.ts index b32e808..4d11bea 100644 --- a/test/events.test.ts +++ b/test/events.test.ts @@ -12,6 +12,7 @@ describe("reportEvent", () => { returnStatus(401, `${baseURL}/${apis.events}`); expect(reportEvent({ apiKey: "apiKey" }, {} as TopsortEvent)).rejects.toEqual({ status: 401, + retry: false, statusText: "Unauthorized", body: {}, }); @@ -19,19 +20,17 @@ describe("reportEvent", () => { it("should handle retryable error", async () => { returnStatus(429, `${baseURL}/${apis.events}`); - expect(reportEvent({ apiKey: "apiKey" }, {} as TopsortEvent)).rejects.toEqual({ - status: 429, - statusText: "Too Many Requests", - body: {}, + expect(reportEvent({ apiKey: "apiKey" }, {} as TopsortEvent)).resolves.toEqual({ + ok: false, + retry: true, }); }); it("should handle server error", async () => { returnStatus(500, `${baseURL}/${apis.events}`); - expect(reportEvent({ apiKey: "apiKey" }, {} as TopsortEvent)).rejects.toEqual({ - status: 500, - statusText: "Internal Server Error", - body: {}, + expect(reportEvent({ apiKey: "apiKey" }, {} as TopsortEvent)).resolves.toEqual({ + ok: false, + retry: true, }); }); @@ -45,7 +44,7 @@ describe("reportEvent", () => { }, {} as TopsortEvent, ), - ).resolves.toEqual({ ok: true }); + ).resolves.toEqual({ ok: true, retry: false }); }); it("should handle fetch error", async () => {