1- import { TestCli } from "@clerc/test-utils" ;
1+ import { TestBaseCli } from "@clerc/test-utils" ;
22import { describe , expect , it } from "vitest" ;
33
44import { defineCommand } from "../src" ;
55
66describe ( "cli" , ( ) => {
77 it ( "should parse" , ( ) => {
8- TestCli ( )
8+ TestBaseCli ( )
99 . command ( "foo" , "foo" )
1010 . on ( "foo" , ( ctx ) => {
1111 expect ( ctx . command . name ) . toBe ( "foo" ) ;
@@ -26,21 +26,21 @@ describe("cli", () => {
2626 } ) ;
2727
2828 it ( "should handle scriptName and name" , ( ) => {
29- const cli = TestCli ( ) . name ( "test name" ) . scriptName ( "test" ) ;
29+ const cli = TestBaseCli ( ) . name ( "test name" ) . scriptName ( "test" ) ;
3030
3131 expect ( cli . _name ) . toBe ( "test name" ) ;
3232 expect ( cli . _scriptName ) . toBe ( "test" ) ;
3333 } ) ;
3434
3535 it ( "should handle return scriptName when name is not set" , ( ) => {
36- const cli = TestCli ( ) ;
36+ const cli = TestBaseCli ( ) ;
3737
3838 expect ( cli . _name ) . toBe ( "test" ) ;
3939 expect ( cli . _scriptName ) . toBe ( "test" ) ;
4040 } ) ;
4141
4242 it ( "should handle root" , ( ) => {
43- TestCli ( )
43+ TestBaseCli ( )
4444 . command ( "" , "root" , {
4545 flags : {
4646 foo : {
@@ -89,7 +89,7 @@ describe("cli", () => {
8989 } )
9090 . parse ( [ "bar" , "--foo" , "baz" , "qux" ] ) ;
9191
92- TestCli ( )
92+ TestBaseCli ( )
9393 . command ( "" , "root" , {
9494 flags : {
9595 foo : {
@@ -133,7 +133,7 @@ describe("cli", () => {
133133 } ) ;
134134
135135 it ( "should parse parameters" , ( ) => {
136- TestCli ( )
136+ TestBaseCli ( )
137137 . command ( "foo" , "foo" , {
138138 parameters : [ "[optional...]" ] ,
139139 } )
@@ -145,7 +145,7 @@ describe("cli", () => {
145145 } ) ;
146146
147147 it ( "should parse boolean flag" , ( ) => {
148- TestCli ( )
148+ TestBaseCli ( )
149149 . command ( "foo" , "foo" , {
150150 flags : {
151151 foo : {
@@ -178,7 +178,7 @@ describe("cli", () => {
178178 } ) ;
179179
180180 it ( "should parse string flag" , ( ) => {
181- TestCli ( )
181+ TestBaseCli ( )
182182 . command ( "foo" , "foo" , {
183183 flags : {
184184 foo : {
@@ -197,7 +197,7 @@ describe("cli", () => {
197197 } ) ;
198198
199199 it ( "should parse number flag" , ( ) => {
200- TestCli ( )
200+ TestBaseCli ( )
201201 . command ( "foo" , "foo" , {
202202 flags : {
203203 foo : {
@@ -216,7 +216,7 @@ describe("cli", () => {
216216 } ) ;
217217
218218 it ( "should parse dot-nested flag" , ( ) => {
219- TestCli ( )
219+ TestBaseCli ( )
220220 . command ( "foo" , "foo" , {
221221 flags : {
222222 foo : {
@@ -238,7 +238,7 @@ describe("cli", () => {
238238 } ) ;
239239
240240 it ( "should parse shorthand flag" , ( ) => {
241- TestCli ( )
241+ TestBaseCli ( )
242242 . command ( "foo" , "foo" )
243243 . on ( "foo" , ( ctx ) => {
244244 expect ( ctx . command . name ) . toBe ( "foo" ) ;
@@ -249,7 +249,7 @@ describe("cli", () => {
249249 } ) ;
250250
251251 it ( "should parse array flag" , ( ) => {
252- TestCli ( )
252+ TestBaseCli ( )
253253 . command ( "foo" , "foo" , {
254254 flags : {
255255 abc : {
@@ -269,7 +269,7 @@ describe("cli", () => {
269269
270270 it ( "should handle interceptor" , ( ) => {
271271 let count = 0 ;
272- TestCli ( )
272+ TestBaseCli ( )
273273 . command ( "foo" , "foo" )
274274 . interceptor ( ( ) => { } )
275275 . on ( "foo" , ( ) => {
@@ -282,7 +282,7 @@ describe("cli", () => {
282282
283283 it ( "should next" , ( ) => {
284284 let count = 0 ;
285- TestCli ( )
285+ TestBaseCli ( )
286286 . command ( "foo" , "foo" )
287287 . interceptor ( ( _ctx , next ) => {
288288 next ( ) ;
@@ -305,12 +305,12 @@ describe("cli", () => {
305305 it ( "should have exact one command" , ( ) => {
306306 expect ( ( ) => {
307307 // @ts -expect-error testing
308- TestCli ( ) . command ( "foo" , "foo" ) . command ( "foo" , "foo" ) ;
308+ TestBaseCli ( ) . command ( "foo" , "foo" ) . command ( "foo" , "foo" ) ;
309309 } ) . toThrow ( ) ;
310310 } ) ;
311311
312312 it ( "should parse nested command" , ( ) => {
313- TestCli ( )
313+ TestBaseCli ( )
314314 . command ( "foo bar" , "foo bar" , {
315315 flags : {
316316 aa : {
@@ -329,7 +329,7 @@ describe("cli", () => {
329329 } ) ;
330330
331331 it ( "shouldn't parse nested command when parent command is called" , ( ) => {
332- TestCli ( )
332+ TestBaseCli ( )
333333 . command ( "foo bar" , "foo bar" , {
334334 flags : {
335335 aa : {
@@ -357,7 +357,7 @@ describe("cli", () => {
357357 } ) ;
358358
359359 it ( "shouldn't parse when command is after command" , ( ) => {
360- TestCli ( )
360+ TestBaseCli ( )
361361 . command ( "foo bar" , "foo bar" , {
362362 flags : {
363363 aa : {
@@ -385,7 +385,7 @@ describe("cli", () => {
385385 } ) ;
386386
387387 it ( "should parse subcommand" , ( ) => {
388- TestCli ( )
388+ TestBaseCli ( )
389389 . command ( "foo bar" , "foo" )
390390 . on ( "foo bar" , ( ctx ) => {
391391 expect ( ctx . command . name ) . toBe ( "foo bar" ) ;
@@ -423,7 +423,7 @@ describe("cli", () => {
423423
424424 it ( "should run matched command" , ( ) => {
425425 let count = 0 ;
426- TestCli ( )
426+ TestBaseCli ( )
427427 . command ( "foo" , "foo" )
428428 . on ( "foo" , ( ) => {
429429 count ++ ;
@@ -435,7 +435,7 @@ describe("cli", () => {
435435 } ) ;
436436
437437 it ( "should resolve parameter with alias correctly" , ( ) => {
438- TestCli ( )
438+ TestBaseCli ( )
439439 . command ( "foo" , "foo" , {
440440 alias : "bar baz" ,
441441 parameters : [ "<param>" ] ,
@@ -448,7 +448,7 @@ describe("cli", () => {
448448
449449 it ( "shouldn't run matched command" , ( ) => {
450450 let count = 0 ;
451- TestCli ( )
451+ TestBaseCli ( )
452452 . command ( "foo" , "foo" )
453453 . on ( "foo" , ( ) => {
454454 count ++ ;
@@ -459,7 +459,7 @@ describe("cli", () => {
459459 } ) ;
460460
461461 it ( "should parse global flag" , ( ) => {
462- TestCli ( )
462+ TestBaseCli ( )
463463 . globalFlag ( "foo" , "foo" , {
464464 type : String ,
465465 default : "bar" ,
@@ -472,7 +472,7 @@ describe("cli", () => {
472472 } ) ;
473473
474474 it ( "should parse global flag with default value" , ( ) => {
475- TestCli ( )
475+ TestBaseCli ( )
476476 . globalFlag ( "foo" , "foo" , {
477477 type : String ,
478478 default : "bar" ,
@@ -485,7 +485,7 @@ describe("cli", () => {
485485 } ) ;
486486
487487 it ( "should override global flag" , ( ) => {
488- TestCli ( )
488+ TestBaseCli ( )
489489 . globalFlag ( "foo" , "foo" , {
490490 type : String ,
491491 default : "bar" ,
@@ -506,7 +506,7 @@ describe("cli", () => {
506506 } ) ;
507507
508508 it ( "should parse parameter with space" , ( ) => {
509- TestCli ( )
509+ TestBaseCli ( )
510510 . command ( "foo" , "foo" , {
511511 parameters : [ "<foo bar>" ] ,
512512 } )
0 commit comments