@@ -576,6 +576,9 @@ describe('createSlice', () => {
576
576
function rejected ( state : any [ ] , action : any ) {
577
577
state . push ( [ 'rejectedReducer' , action ] )
578
578
}
579
+ function settled ( state : any [ ] , action : any ) {
580
+ state . push ( [ 'settledReducer' , action ] )
581
+ }
579
582
580
583
test ( 'successful thunk' , async ( ) => {
581
584
const slice = createSlice ( {
@@ -586,7 +589,7 @@ describe('createSlice', () => {
586
589
function payloadCreator ( arg , api ) {
587
590
return Promise . resolve ( 'resolved payload' )
588
591
} ,
589
- { pending, fulfilled, rejected }
592
+ { pending, fulfilled, rejected, settled }
590
593
) ,
591
594
} ) ,
592
595
} )
@@ -610,6 +613,13 @@ describe('createSlice', () => {
610
613
payload : 'resolved payload' ,
611
614
} ,
612
615
] ,
616
+ [
617
+ 'settledReducer' ,
618
+ {
619
+ type : 'test/thunkReducers/fulfilled' ,
620
+ payload : 'resolved payload' ,
621
+ } ,
622
+ ] ,
613
623
] )
614
624
} )
615
625
@@ -623,7 +633,7 @@ describe('createSlice', () => {
623
633
function payloadCreator ( arg , api ) : any {
624
634
throw new Error ( '' )
625
635
} ,
626
- { pending, fulfilled, rejected }
636
+ { pending, fulfilled, rejected, settled }
627
637
) ,
628
638
} ) ,
629
639
} )
@@ -647,6 +657,13 @@ describe('createSlice', () => {
647
657
payload : undefined ,
648
658
} ,
649
659
] ,
660
+ [
661
+ 'settledReducer' ,
662
+ {
663
+ type : 'test/thunkReducers/rejected' ,
664
+ payload : undefined ,
665
+ } ,
666
+ ] ,
650
667
] )
651
668
} )
652
669
@@ -669,6 +686,7 @@ describe('createSlice', () => {
669
686
pending,
670
687
fulfilled,
671
688
rejected,
689
+ settled,
672
690
}
673
691
) ,
674
692
} ) ,
@@ -687,6 +705,14 @@ describe('createSlice', () => {
687
705
meta : { condition : true } ,
688
706
} ,
689
707
] ,
708
+ [
709
+ 'settledReducer' ,
710
+ {
711
+ type : 'test/thunkReducers/rejected' ,
712
+ payload : undefined ,
713
+ meta : { condition : true } ,
714
+ } ,
715
+ ] ,
690
716
] )
691
717
} )
692
718
@@ -699,13 +725,14 @@ describe('createSlice', () => {
699
725
function payloadCreator ( arg , api ) {
700
726
return Promise . resolve ( 'resolved payload' )
701
727
} ,
702
- { pending, fulfilled }
728
+ { pending, fulfilled, settled }
703
729
) ,
704
730
} ) ,
705
731
} )
706
732
707
733
expect ( slice . caseReducers . thunkReducers . pending ) . toBe ( pending )
708
734
expect ( slice . caseReducers . thunkReducers . fulfilled ) . toBe ( fulfilled )
735
+ expect ( slice . caseReducers . thunkReducers . settled ) . toBe ( settled )
709
736
// even though it is not defined above, this should at least be a no-op function to match the TypeScript typings
710
737
// and should be callable as a reducer even if it does nothing
711
738
expect ( ( ) =>
0 commit comments