Skip to content

Commit

Permalink
✅ update retry unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kuitos committed Feb 19, 2020
1 parent db153cb commit 38e65b6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/__tests__/test-retryAdapterEnhancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ test('should return the result immediately while the request succeed', async (t)
const spyFn = spy();
const mockedAdapter = (config: any) => {
spyFn();
return Promise.resolve(config);
if (spyFn.calledTwice) {
return Promise.resolve(config);
}

return Promise.reject(config);
};
const http = axios.create({
adapter: retryAdapterEnhancer(mockedAdapter),
});

await http.get('/test');

t.truthy(spyFn.calledOnce);
t.truthy(spyFn.calledTwice);
});

test('should throw an exception while request still failed after retry', async (t) => {
Expand Down

0 comments on commit 38e65b6

Please # to comment.