@@ -226,4 +226,101 @@ describe('TanStack Query React Client Generation', () => {
226
226
) ;
227
227
} ) ;
228
228
} ) ;
229
+
230
+ describe ( '--default-client-callbacks with specific hooks' , ( ) => {
231
+ beforeAll ( async ( ) => {
232
+ const { QraftCommand } = await import (
233
+ '@openapi-qraft/plugin/lib/QraftCommand'
234
+ ) ;
235
+ const { plugin } = await import ( './plugin.js' ) ;
236
+ const command = new QraftCommand ( ) ;
237
+ plugin . setupCommand ( command ) ;
238
+
239
+ await command . parseAsync ( [
240
+ 'dummy-node' ,
241
+ 'dummy-qraft-bin' ,
242
+ openAPIDocumentFixturePath ,
243
+ '--clean' ,
244
+ '-o' ,
245
+ '/mock-fs' ,
246
+ '--openapi-types-import-path' ,
247
+ '../../openapi.d.ts' ,
248
+ '--default-client-callbacks' ,
249
+ 'useQuery' ,
250
+ 'useMutation' ,
251
+ ] ) ;
252
+ } ) ;
253
+
254
+ test ( 'create-api-operation-client.ts' , async ( ) => {
255
+ expect (
256
+ fs . readFileSync ( '/mock-fs/create-api-operation-client.ts' , 'utf-8' )
257
+ ) . toMatchFileSnapshot (
258
+ './__snapshots__/default-client-callbacks/specific-hooks-create-api-operation-client.ts.snapshot.ts'
259
+ ) ;
260
+ } ) ;
261
+ } ) ;
262
+
263
+ describe ( '--default-client-callbacks with "all" value' , ( ) => {
264
+ beforeAll ( async ( ) => {
265
+ const { QraftCommand } = await import (
266
+ '@openapi-qraft/plugin/lib/QraftCommand'
267
+ ) ;
268
+ const { plugin } = await import ( './plugin.js' ) ;
269
+ const command = new QraftCommand ( ) ;
270
+ plugin . setupCommand ( command ) ;
271
+
272
+ await command . parseAsync ( [
273
+ 'dummy-node' ,
274
+ 'dummy-qraft-bin' ,
275
+ openAPIDocumentFixturePath ,
276
+ '--clean' ,
277
+ '-o' ,
278
+ '/mock-fs' ,
279
+ '--openapi-types-import-path' ,
280
+ '../../openapi.d.ts' ,
281
+ '--default-client-callbacks' ,
282
+ 'all' ,
283
+ ] ) ;
284
+ } ) ;
285
+
286
+ test ( 'create-api-operation-client.ts' , async ( ) => {
287
+ expect (
288
+ fs . readFileSync ( '/mock-fs/create-api-operation-client.ts' , 'utf-8' )
289
+ ) . toMatchFileSnapshot (
290
+ './__snapshots__/default-client-callbacks/all-callbacks-create-api-operation-client.ts.snapshot.ts'
291
+ ) ;
292
+ } ) ;
293
+ } ) ;
294
+
295
+ describe ( '--default-client-callbacks with "none" value' , ( ) => {
296
+ beforeAll ( async ( ) => {
297
+ const { QraftCommand } = await import (
298
+ '@openapi-qraft/plugin/lib/QraftCommand'
299
+ ) ;
300
+ const { plugin } = await import ( './plugin.js' ) ;
301
+ const command = new QraftCommand ( ) ;
302
+ plugin . setupCommand ( command ) ;
303
+
304
+ await command . parseAsync ( [
305
+ 'dummy-node' ,
306
+ 'dummy-qraft-bin' ,
307
+ openAPIDocumentFixturePath ,
308
+ '--clean' ,
309
+ '-o' ,
310
+ '/mock-fs' ,
311
+ '--openapi-types-import-path' ,
312
+ '../../openapi.d.ts' ,
313
+ '--default-client-callbacks' ,
314
+ 'none' ,
315
+ ] ) ;
316
+ } ) ;
317
+
318
+ test ( 'create-api-operation-client.ts' , async ( ) => {
319
+ expect (
320
+ fs . readFileSync ( '/mock-fs/create-api-operation-client.ts' , 'utf-8' )
321
+ ) . toMatchFileSnapshot (
322
+ './__snapshots__/default-client-callbacks/none-callbacks-create-api-operation-client.ts.snapshot.ts'
323
+ ) ;
324
+ } ) ;
325
+ } ) ;
229
326
} ) ;
0 commit comments