|
|
@ -6,7 +6,7 @@ describe('getFetchWithTimeout', () => { |
|
|
|
it('fetches a url', async () => { |
|
|
|
it('fetches a url', async () => { |
|
|
|
nock('https://api.infura.io').get('/money').reply(200, '{"hodl": false}'); |
|
|
|
nock('https://api.infura.io').get('/money').reply(200, '{"hodl": false}'); |
|
|
|
|
|
|
|
|
|
|
|
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30); |
|
|
|
const fetchWithTimeout = getFetchWithTimeout(); |
|
|
|
const response = await ( |
|
|
|
const response = await ( |
|
|
|
await fetchWithTimeout('https://api.infura.io/money') |
|
|
|
await fetchWithTimeout('https://api.infura.io/money') |
|
|
|
).json(); |
|
|
|
).json(); |
|
|
@ -46,15 +46,9 @@ describe('getFetchWithTimeout', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('throws on invalid timeout', async () => { |
|
|
|
it('throws on invalid timeout', async () => { |
|
|
|
await expect(() => getFetchWithTimeout()).toThrow( |
|
|
|
|
|
|
|
'Must specify positive integer timeout.', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
await expect(() => getFetchWithTimeout(-1)).toThrow( |
|
|
|
await expect(() => getFetchWithTimeout(-1)).toThrow( |
|
|
|
'Must specify positive integer timeout.', |
|
|
|
'Must specify positive integer timeout.', |
|
|
|
); |
|
|
|
); |
|
|
|
await expect(() => getFetchWithTimeout({})).toThrow( |
|
|
|
|
|
|
|
'Must specify positive integer timeout.', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
await expect(() => getFetchWithTimeout(true)).toThrow( |
|
|
|
await expect(() => getFetchWithTimeout(true)).toThrow( |
|
|
|
'Must specify positive integer timeout.', |
|
|
|
'Must specify positive integer timeout.', |
|
|
|
); |
|
|
|
); |
|
|
|