Skip to content
Myr

Normalize retry option defaults when undefined

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by Sindre Sorhus · parent 4fd8c28 · Browse files · 2 files+26 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−1 removed

  • tests:+21 added−0 removed
  • other:+5 added−1 removed

2 files+26 added−1 removed

modified:source/utils/normalize.ts+5 added-1 removed
modified:test/retry.ts+21 added
582 unmodified lines
583584 await server.close();585});586587test('retry options ignore undefined overrides and keep defaults', async t => {588 let requestCount = 0;589590 const server = await createHttpTestServer();591 server.get('/', (_request, response) => {592 requestCount++;593 response.sendStatus(500);594 });595596 await t.throwsAsync(ky(server.url, {597 retry: {598 limit: undefined,599 },600 }).text(), {message: /Internal Server Error/});601602 // Default limit is 2, so request should be attempted 3 times603 t.is(requestCount, defaultRetryCount + 1);604605 await server.close();606});607608test('respect maximum backoffLimit', async t => {609 const retryCount = 4;610 let requestCount = 0;611
837 unmodified lines