From 220d1af09baa0915e41da07a55421146651ea0dd Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:40:04 +0530 Subject: [PATCH] fix: change tests to conform to custom behaviour for retries --- .fernignore | 1 + tests/unit/fetcher/requestWithRetries.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.fernignore b/.fernignore index 8bc1917..581654f 100644 --- a/.fernignore +++ b/.fernignore @@ -2,3 +2,4 @@ src/GooeyClient.ts src/index.ts src/core/fetcher/requestWithRetries.ts +tests/unit/fetcher/requestWithRetries.test.ts diff --git a/tests/unit/fetcher/requestWithRetries.test.ts b/tests/unit/fetcher/requestWithRetries.test.ts index b53e043..7a44fc2 100644 --- a/tests/unit/fetcher/requestWithRetries.test.ts +++ b/tests/unit/fetcher/requestWithRetries.test.ts @@ -25,7 +25,7 @@ describe("Test exponential backoff", () => { .mockResolvedValueOnce(new Response("", { status: 408 })) .mockResolvedValueOnce(new Response("", { status: 409 })) .mockResolvedValueOnce(new Response("", { status: 429 })) - .mockResolvedValueOnce(new Response("", { status: 500 })) + .mockResolvedValueOnce(new Response("", { status: 503 })) .mockResolvedValueOnce(new Response("", { status: 502 })) .mockResolvedValueOnce(new Response("", { status: 200 })) .mockResolvedValueOnce(new Response("", { status: 408 })); @@ -69,7 +69,7 @@ describe("Test exponential backoff", () => { }); it("should retry with exponential backoff timing", async () => { - mockFetch.mockResolvedValue(new Response("", { status: 500 })); + mockFetch.mockResolvedValue(new Response("", { status: 502 })); const maxRetries = 7; const responsePromise = requestWithRetries(() => mockFetch(), maxRetries); expect(mockFetch).toHaveBeenCalledTimes(1); @@ -80,6 +80,6 @@ describe("Test exponential backoff", () => { expect(mockFetch).toHaveBeenCalledTimes(Math.min(i + 2, maxRetries + 1)); } const response = await responsePromise; - expect(response.status).toBe(500); + expect(response.status).toBe(502); }); });