File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
packages/toolkit/src/query/tests Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -403,4 +403,39 @@ describe('configuration', () => {
403
403
404
404
expect ( baseBaseQuery ) . toHaveBeenCalledTimes ( 6 )
405
405
} )
406
+
407
+ test ( 'retryCondition also works with mutations' , async ( ) => {
408
+ const baseBaseQuery = jest . fn <
409
+ ReturnType < BaseQueryFn > ,
410
+ Parameters < BaseQueryFn >
411
+ > ( )
412
+
413
+ baseBaseQuery
414
+ . mockRejectedValueOnce ( new Error ( 'rejected' ) )
415
+ . mockRejectedValueOnce ( new Error ( 'hello retryCondition' ) )
416
+ . mockRejectedValueOnce ( new Error ( 'rejected' ) )
417
+ . mockResolvedValue ( { error : 'hello retryCondition' } )
418
+
419
+ const baseQuery = retry ( baseBaseQuery , { } )
420
+ const api = createApi ( {
421
+ baseQuery,
422
+ endpoints : ( build ) => ( {
423
+ m1 : build . mutation ( {
424
+ query : ( ) => ( { method : 'PUT' } ) ,
425
+ extraOptions : {
426
+ retryCondition : ( e ) => e . data === 'hello retryCondition' ,
427
+ }
428
+ } ) ,
429
+ } ) ,
430
+ } )
431
+
432
+ const storeRef = setupApiStore ( api , undefined , {
433
+ withoutTestLifecycles : true ,
434
+ } )
435
+ storeRef . store . dispatch ( api . endpoints . m1 . initiate ( { } ) )
436
+
437
+ await loopTimers ( )
438
+
439
+ expect ( baseBaseQuery ) . toHaveBeenCalledTimes ( 4 )
440
+ } )
406
441
} )
You can’t perform that action at this time.
0 commit comments