@@ -223,6 +223,41 @@ describe("client", () => {
223
223
expect ( await screen . findByText ( "Something went wrong" ) ) . toBeDefined ( ) ;
224
224
errorSpy . mockRestore ( ) ;
225
225
} ) ;
226
+
227
+ it ( "should use provided custom queryClient" , async ( ) => {
228
+ const fetchClient = createFetchClient < paths > ( { baseUrl } ) ;
229
+ const client = createClient ( fetchClient ) ;
230
+ const customQueryClient = new QueryClient ( { } ) ;
231
+
232
+ function Page ( ) {
233
+ const { data } = client . useSuspenseQuery (
234
+ "get" ,
235
+ "/blogposts/{post_id}" ,
236
+ {
237
+ params : {
238
+ path : {
239
+ post_id : "1" ,
240
+ } ,
241
+ } ,
242
+ } ,
243
+ { } ,
244
+ customQueryClient ,
245
+ ) ;
246
+ return < div > data: { data ?. title } </ div > ;
247
+ }
248
+
249
+ useMockRequestHandler ( {
250
+ baseUrl,
251
+ method : "get" ,
252
+ path : "/blogposts/:post_id" ,
253
+ status : 200 ,
254
+ body : { title : "Hello" } ,
255
+ } ) ;
256
+
257
+ const rendered = render ( < Page /> ) ;
258
+
259
+ await waitFor ( ( ) => rendered . findByText ( "data: Hello" ) ) ;
260
+ } ) ;
226
261
} ) ;
227
262
228
263
describe ( "useMutation" , ( ) => {
@@ -290,6 +325,7 @@ describe("client", () => {
290
325
return (
291
326
< div >
292
327
< button
328
+ type = "button"
293
329
onClick = { ( ) =>
294
330
mutation . mutate ( {
295
331
body : {
@@ -316,7 +352,7 @@ describe("client", () => {
316
352
body : { message : "Hello" } ,
317
353
} ) ;
318
354
319
- const rendered = render ( < Page > </ Page > ) ;
355
+ const rendered = render ( < Page / >) ;
320
356
321
357
await rendered . findByText ( "data: null, status: idle" ) ;
322
358
@@ -378,6 +414,7 @@ describe("client", () => {
378
414
return (
379
415
< div >
380
416
< button
417
+ type = "button"
381
418
onClick = { ( ) =>
382
419
mutation . mutateAsync ( {
383
420
body : {
@@ -404,7 +441,7 @@ describe("client", () => {
404
441
body : { message : "Hello" } ,
405
442
} ) ;
406
443
407
- const rendered = render ( < Page > </ Page > ) ;
444
+ const rendered = render ( < Page / >) ;
408
445
409
446
await rendered . findByText ( "data: null, status: idle" ) ;
410
447
0 commit comments