Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit c0af20a

Browse files
committed
testing if we can use the custom axios instance
1 parent 0e19078 commit c0af20a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,30 @@ test('ensure that failed requests are not retried forever', async t => {
606606
await t.throws(client.flush())
607607
})
608608

609+
test('ensure we can pass our own axios instance', async t => {
610+
const axios = require('axios')
611+
const myAxiosInstance = axios.create()
612+
const stubAxiosPost = stub(myAxiosInstance, 'post').resolves()
613+
const client = createClient({
614+
axiosInstance: myAxiosInstance,
615+
host: 'https://my-dummy-host.com',
616+
path: '/test/path'
617+
})
618+
619+
const callback = spy()
620+
client.queue = [
621+
{
622+
message: 'something',
623+
callback
624+
}
625+
]
626+
627+
client.flush()
628+
629+
t.true(stubAxiosPost.called)
630+
t.true(stubAxiosPost.alwaysCalledWith('https://my-dummy-host.com/test/path'))
631+
})
632+
609633
test('ensure other axios clients are not impacted by axios-retry', async t => {
610634
let client = createClient() // eslint-disable-line
611635
const axios = require('axios')

0 commit comments

Comments
 (0)