Skip to content

Commit

Permalink
fix: change tests to conform to custom behaviour for retries
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Sep 4, 2024
1 parent 27f3ae2 commit 220d1af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
src/GooeyClient.ts
src/index.ts
src/core/fetcher/requestWithRetries.ts
tests/unit/fetcher/requestWithRetries.test.ts
6 changes: 3 additions & 3 deletions tests/unit/fetcher/requestWithRetries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
});

0 comments on commit 220d1af

Please sign in to comment.