File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,43 @@ describe('sendRequest', () => {
227
227
expect ( mockAxiosInstance . mock . calls ) . toHaveLength ( 1 ) ;
228
228
} ) ;
229
229
230
+ it ( 'should include any specified axios request options' , async ( ) => {
231
+ const parameters = {
232
+ defaultOptions : {
233
+ body : 'post=body' ,
234
+ formData : '' ,
235
+ qs : { } ,
236
+ method : 'POST' ,
237
+ url : 'https://example.ibm.com/v1' ,
238
+ headers : {
239
+ 'test-header' : 'test-header-value' ,
240
+ } ,
241
+ responseType : 'buffer' ,
242
+ axiosOptions : {
243
+ signal : 'mock' ,
244
+ } ,
245
+ } ,
246
+ } ;
247
+
248
+ mockAxiosInstance . mockResolvedValue ( axiosResolveValue ) ;
249
+
250
+ const res = await requestWrapperInstance . sendRequest ( parameters ) ;
251
+ // assert results
252
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . data ) . toEqual ( 'post=body' ) ;
253
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . url ) . toEqual ( 'https://example.ibm.com/v1' ) ;
254
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . headers ) . toEqual ( {
255
+ 'Accept-Encoding' : 'gzip' ,
256
+ 'test-header' : 'test-header-value' ,
257
+ } ) ;
258
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . method ) . toEqual ( parameters . defaultOptions . method ) ;
259
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . responseType ) . toEqual (
260
+ parameters . defaultOptions . responseType
261
+ ) ;
262
+ expect ( mockAxiosInstance . mock . calls [ 0 ] [ 0 ] . signal ) . toEqual ( 'mock' ) ;
263
+ expect ( res ) . toEqual ( expectedResult ) ;
264
+ expect ( mockAxiosInstance . mock . calls ) . toHaveLength ( 1 ) ;
265
+ } ) ;
266
+
230
267
it ( 'sendRequest should strip trailing slashes' , async ( ) => {
231
268
const parameters = {
232
269
defaultOptions : {
You can’t perform that action at this time.
0 commit comments