@@ -108,6 +108,34 @@ test('should handle errors even after retries', async t => {
108
108
mock . interceptors . forEach ( nock . removeInterceptor )
109
109
} )
110
110
111
+ test ( 'should retry with same url + querystring' , async t => {
112
+ const calledUrls = [ ]
113
+ const retrySpy = sinon . spy ( ( error ) => {
114
+ if ( error && error . options ) {
115
+ calledUrls . push ( error . options . url )
116
+ }
117
+ } )
118
+ const client = new Client ( { api_key : 'secret' , apihost : 'test_host' , proxy : '' , retry : { retries : 3 , onRetry : retrySpy } } )
119
+ const METHOD = 'GET'
120
+ const PATH = '/dont/add/to/querystring'
121
+ const options = { qs : { bob : 'your uncle' } }
122
+ const mock = nock ( 'https://test_host' )
123
+ . get ( PATH )
124
+ . query ( { bob : 'your uncle' } )
125
+ . times ( 4 )
126
+ . replyWithError ( 'simulated error' )
127
+ . get ( PATH ) . times ( 1 ) . reply ( 200 , 'not enough retries to come here' )
128
+
129
+ const error = await t . throwsAsync ( client . request ( METHOD , PATH , options ) )
130
+ t . truthy ( error . message )
131
+ t . assert ( error . message . includes ( 'simulated error' ) )
132
+ t . assert ( calledUrls . length === 3 )
133
+ t . assert ( calledUrls [ 0 ] === calledUrls [ 1 ] )
134
+ t . assert ( calledUrls [ 0 ] === calledUrls [ 2 ] )
135
+
136
+ mock . interceptors . forEach ( nock . removeInterceptor )
137
+ } )
138
+
111
139
// end client request tests
112
140
113
141
test ( 'should use default constructor options' , t => {
0 commit comments