From 731edbfcde97776086ac17a9fc2e9d0f08862511 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 16 Nov 2023 20:39:04 +0200 Subject: [PATCH] test: Almost complete coverage (#239) The only uncovered branch is: (axiosError as any).config = axiosError.config || {}; // Allow for wider range of errors which I have no idea how to reach. --- test/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/index.ts b/test/index.ts index 4798986..85c2f6d 100644 --- a/test/index.ts +++ b/test/index.ts @@ -652,6 +652,17 @@ describe('retry-axios', () => { assert.strictEqual(scopes[1].isDone(), false); }); + it('should not retry if Retry-After is invalid', async () => { + const scopes = [ + nock(url).get('/').reply(429, undefined, {'Retry-After': 'foo'}), + nock(url).get('/').reply(200, 'toast'), + ]; + interceptorId = rax.attach(); + const cfg: rax.RaxConfig = {url, raxConfig: {maxRetryAfter: 1000}}; + await assert.rejects(axios(cfg)); + assert.strictEqual(scopes[1].isDone(), false); + }); + it('should use maxRetryDelay', async function () { this.timeout(1000); // Short timeout to trip test if delay longer than expected const scopes = [