Skip to content

Commit 9384f72

Browse files
committed
add example to reproduce defect of serializeQueryArgs with skipToken
1 parent 24286f1 commit 9384f72

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/toolkit/src/query/tests/buildHooks.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ const api = createApi({
125125
return true
126126
},
127127
}),
128+
queryWithDeepArg: build.query<string, { param: {nested: string} }>({
129+
query: ({param: {nested}}) => nested,
130+
serializeQueryArgs: ({queryArgs}) => {
131+
return queryArgs.param.nested
132+
}
133+
}),
128134
}),
129135
})
130136

@@ -667,6 +673,12 @@ describe('hooks tests', () => {
667673
await screen.findByText('ID: 3')
668674
})
669675

676+
test(`useQuery shouldn't call args serialization if request skipped`, async () => {
677+
expect(() => renderHook(() => api.endpoints.queryWithDeepArg.useQuery(skipToken), {
678+
wrapper: storeRef.wrapper,
679+
})).not.toThrow()
680+
})
681+
670682
test(`useQuery gracefully handles bigint types`, async () => {
671683
function ItemList() {
672684
const [pageNumber, setPageNumber] = useState(0)

0 commit comments

Comments
 (0)