@@ -21,6 +21,24 @@ describe("args", () => {
2121 const result = getArg ( args , { name : "name" , alias : "n" } ) ;
2222 expect ( result ) . toBe ( "value" ) ;
2323 } ) ;
24+ it ( "should convert bool string to true" , ( ) => {
25+ const args = [ "--someBool" , "true" ] ;
26+ const result = getArg ( args , {
27+ name : "someBool" ,
28+ alias : "sb" ,
29+ type : "bool" ,
30+ } ) ;
31+ expect ( result ) . toBe ( true ) ;
32+ } ) ;
33+ it ( "should convert bool string to false" , ( ) => {
34+ const args = [ "--someBool" , "false" ] ;
35+ const result = getArg ( args , {
36+ name : "someBool" ,
37+ alias : "sb" ,
38+ type : "bool" ,
39+ } ) ;
40+ expect ( result ) . toBe ( false ) ;
41+ } ) ;
2442 it ( "should default value to true if no next value" , ( ) => {
2543 const args = [ "--someBool" ] ;
2644 const result = getArg ( args , {
@@ -30,7 +48,7 @@ describe("args", () => {
3048 } ) ;
3149 expect ( result ) . toBe ( true ) ;
3250 } ) ;
33- it ( "should default value to true if next value is param " , ( ) => {
51+ it ( "should default value to true if next value is --name " , ( ) => {
3452 const args = [ "--someBool" , "--someOtherBool" ] ;
3553 const result = getArg ( args , {
3654 name : "someBool" ,
@@ -39,4 +57,13 @@ describe("args", () => {
3957 } ) ;
4058 expect ( result ) . toBe ( true ) ;
4159 } ) ;
60+ it ( "should default value to true if next value is -alias" , ( ) => {
61+ const args = [ "--someBool" , "-a" ] ;
62+ const result = getArg ( args , {
63+ name : "someBool" ,
64+ alias : "sb" ,
65+ type : "bool" ,
66+ } ) ;
67+ expect ( result ) . toBe ( true ) ;
68+ } ) ;
4269} ) ;
0 commit comments