@@ -17,12 +17,13 @@ describe('createAsyncThunk', () => {
1717
1818 const result = 42
1919 const args = 123
20- const requestId = '1 '
20+ let generatedRequestId = ''
2121
2222 const thunkActionCreator = createAsyncThunk (
2323 'testType' ,
24- async ( args : number ) => {
24+ async ( args : number , { requestId } ) => {
2525 passedArgs = args
26+ generatedRequestId = requestId
2627 return result
2728 }
2829 )
@@ -35,31 +36,32 @@ describe('createAsyncThunk', () => {
3536
3637 expect ( dispatch ) . toHaveBeenNthCalledWith (
3738 1 ,
38- thunkActionCreator . pending ( args , requestId )
39+ thunkActionCreator . pending ( args , generatedRequestId )
3940 )
4041
4142 expect ( dispatch ) . toHaveBeenNthCalledWith (
4243 2 ,
43- thunkActionCreator . fulfilled ( result , args , requestId )
44+ thunkActionCreator . fulfilled ( result , args , generatedRequestId )
4445 )
4546
4647 expect ( dispatch ) . toHaveBeenNthCalledWith (
4748 3 ,
48- thunkActionCreator . finished ( args , requestId )
49+ thunkActionCreator . finished ( args , generatedRequestId )
4950 )
5051 } )
5152
5253 it ( 'accepts arguments and dispatches the actions on reject' , async ( ) => {
5354 const dispatch = jest . fn ( )
5455
5556 const args = 123
56- const requestId = '1 '
57+ let generatedRequestId = ''
5758
5859 const error = new Error ( 'Panic!' )
5960
6061 const thunkActionCreator = createAsyncThunk (
6162 'testType' ,
62- async ( args : number ) => {
63+ async ( args : number , { requestId } ) => {
64+ generatedRequestId = requestId
6365 throw error
6466 }
6567 )
@@ -70,17 +72,17 @@ describe('createAsyncThunk', () => {
7072
7173 expect ( dispatch ) . toHaveBeenNthCalledWith (
7274 1 ,
73- thunkActionCreator . pending ( args , requestId )
75+ thunkActionCreator . pending ( args , generatedRequestId )
7476 )
7577
7678 expect ( dispatch ) . toHaveBeenNthCalledWith (
7779 2 ,
78- thunkActionCreator . rejected ( error , args , requestId )
80+ thunkActionCreator . rejected ( error , args , generatedRequestId )
7981 )
8082
8183 expect ( dispatch ) . toHaveBeenNthCalledWith (
8284 3 ,
83- thunkActionCreator . finished ( args , requestId )
85+ thunkActionCreator . finished ( args , generatedRequestId )
8486 )
8587 } )
8688} )
0 commit comments