Skip to content

Commit 9b1acb3

Browse files
committed
Add test for cAT.withTypes() runtime
1 parent 3f78f9d commit 9b1acb3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/toolkit/src/tests/createAsyncThunk.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,4 +953,18 @@ describe('meta', () => {
953953
ret.meta.extraProp
954954
}
955955
})
956+
957+
test('typed createAsyncThunk.withTypes', () => {
958+
const typedCAT = createAsyncThunk.withTypes<{
959+
state: { s: string }
960+
rejectValue: string
961+
extra: { s: string; n: number }
962+
}>()
963+
const thunk = typedCAT('a', () => 'b')
964+
const expectFunction = expect.any(Function)
965+
expect(thunk.fulfilled).toEqual(expectFunction)
966+
expect(thunk.pending).toEqual(expectFunction)
967+
expect(thunk.rejected).toEqual(expectFunction)
968+
expect(thunk.fulfilled.type).toBe('a/fulfilled')
969+
})
956970
})

0 commit comments

Comments
 (0)