55const  test  =  require ( 'tape' ) ; 
66const  {  parseArgs }  =  require ( '../index.js' ) ; 
77
8- test ( 'defaultValue  must be a boolean when option type is boolean' ,  ( t )  =>  { 
8+ test ( 'default  must be a boolean when option type is boolean' ,  ( t )  =>  { 
99  const  args  =  [ ] ; 
10-   const  options  =  {  alpha : {  type : 'boolean' ,  defaultValue : 'not a boolean'  }  } ; 
10+   const  options  =  {  alpha : {  type : 'boolean' ,  default : 'not a boolean'  }  } ; 
1111  t . throws ( ( )  =>  { 
1212    parseArgs ( {  args,  options } ) ; 
13-   } ,  / a l p h a \. d e f a u l t V a l u e   m u s t   b e   B o o l e a n / 
13+   } ,  / a l p h a \. d e f a u l t   m u s t   b e   B o o l e a n / 
1414  ) ; 
1515  t . end ( ) ; 
1616} ) ; 
1717
18- test ( 'defaultValue  must be a boolean array when option type is boolean and multiple' ,  ( t )  =>  { 
18+ test ( 'default  must be a boolean array when option type is boolean and multiple' ,  ( t )  =>  { 
1919  const  args  =  [ ] ; 
20-   const  options  =  {  alpha : {  type : 'boolean' ,  multiple : true ,  defaultValue : 'not an array'  }  } ; 
20+   const  options  =  {  alpha : {  type : 'boolean' ,  multiple : true ,  default : 'not an array'  }  } ; 
2121  t . throws ( ( )  =>  { 
2222    parseArgs ( {  args,  options } ) ; 
23-   } ,  / a l p h a \. d e f a u l t V a l u e   m u s t   b e   A r r a y / 
23+   } ,  / a l p h a \. d e f a u l t   m u s t   b e   A r r a y / 
2424  ) ; 
2525  t . end ( ) ; 
2626} ) ; 
2727
28- test ( 'defaultValue  must be a boolean array when option type is string and multiple is true' ,  ( t )  =>  { 
28+ test ( 'default  must be a boolean array when option type is string and multiple is true' ,  ( t )  =>  { 
2929  const  args  =  [ ] ; 
30-   const  options  =  {  alpha : {  type : 'boolean' ,  multiple : true ,  defaultValue : [ true ,  true ,  42 ]  }  } ; 
30+   const  options  =  {  alpha : {  type : 'boolean' ,  multiple : true ,  default : [ true ,  true ,  42 ]  }  } ; 
3131  t . throws ( ( )  =>  { 
3232    parseArgs ( {  args,  options } ) ; 
33-   } ,  / a l p h a \. d e f a u l t V a l u e \[ 2 \]   m u s t   b e   B o o l e a n / 
33+   } ,  / a l p h a \. d e f a u l t \[ 2 \]   m u s t   b e   B o o l e a n / 
3434  ) ; 
3535  t . end ( ) ; 
3636} ) ; 
3737
38- test ( 'defaultValue  must be a string when option type is string' ,  ( t )  =>  { 
38+ test ( 'default  must be a string when option type is string' ,  ( t )  =>  { 
3939  const  args  =  [ ] ; 
40-   const  options  =  {  alpha : {  type : 'string' ,  defaultValue : true  }  } ; 
40+   const  options  =  {  alpha : {  type : 'string' ,  default : true  }  } ; 
4141  t . throws ( ( )  =>  { 
4242    parseArgs ( {  args,  options } ) ; 
43-   } ,  / a l p h a \. d e f a u l t V a l u e   m u s t   b e   S t r i n g / 
43+   } ,  / a l p h a \. d e f a u l t   m u s t   b e   S t r i n g / 
4444  ) ; 
4545  t . end ( ) ; 
4646} ) ; 
4747
48- test ( 'defaultValue  must be an array when option type is string and multiple is true' ,  ( t )  =>  { 
48+ test ( 'default  must be an array when option type is string and multiple is true' ,  ( t )  =>  { 
4949  const  args  =  [ ] ; 
50-   const  options  =  {  alpha : {  type : 'string' ,  multiple : true ,  defaultValue : 'not an array'  }  } ; 
50+   const  options  =  {  alpha : {  type : 'string' ,  multiple : true ,  default : 'not an array'  }  } ; 
5151  t . throws ( ( )  =>  { 
5252    parseArgs ( {  args,  options } ) ; 
53-   } ,  / a l p h a \. d e f a u l t V a l u e   m u s t   b e   A r r a y / 
53+   } ,  / a l p h a \. d e f a u l t   m u s t   b e   A r r a y / 
5454  ) ; 
5555  t . end ( ) ; 
5656} ) ; 
5757
58- test ( 'defaultValue  must be a string array when option type is string and multiple is true' ,  ( t )  =>  { 
58+ test ( 'default  must be a string array when option type is string and multiple is true' ,  ( t )  =>  { 
5959  const  args  =  [ ] ; 
60-   const  options  =  {  alpha : {  type : 'string' ,  multiple : true ,  defaultValue : [ 'str' ,  42 ]  }  } ; 
60+   const  options  =  {  alpha : {  type : 'string' ,  multiple : true ,  default : [ 'str' ,  42 ]  }  } ; 
6161  t . throws ( ( )  =>  { 
6262    parseArgs ( {  args,  options } ) ; 
63-   } ,  / a l p h a \. d e f a u l t V a l u e \[ 1 \]   m u s t   b e   S t r i n g / 
63+   } ,  / a l p h a \. d e f a u l t \[ 1 \]   m u s t   b e   S t r i n g / 
6464  ) ; 
6565  t . end ( ) ; 
6666} ) ; 
6767
68- test ( 'defaultValue  accepted input when multiple is true' ,  ( t )  =>  { 
68+ test ( 'default  accepted input when multiple is true' ,  ( t )  =>  { 
6969  const  args  =  [ '--inputStringArr' ,  'c' ,  '--inputStringArr' ,  'd' ,  '--inputBoolArr' ,  '--inputBoolArr' ] ; 
7070  const  options  =  { 
71-     inputStringArr : {  type : 'string' ,  multiple : true ,  defaultValue : [ 'a' ,  'b' ]  } , 
72-     emptyStringArr : {  type : 'string' ,  multiple : true ,  defaultValue : [ ]  } , 
73-     fullStringArr : {  type : 'string' ,  multiple : true ,  defaultValue : [ 'a' ,  'b' ]  } , 
74-     inputBoolArr : {  type : 'boolean' ,  multiple : true ,  defaultValue : [ false ,  true ,  false ]  } , 
75-     emptyBoolArr : {  type : 'boolean' ,  multiple : true ,  defaultValue : [ ]  } , 
76-     fullBoolArr : {  type : 'boolean' ,  multiple : true ,  defaultValue : [ false ,  true ,  false ]  } , 
71+     inputStringArr : {  type : 'string' ,  multiple : true ,  default : [ 'a' ,  'b' ]  } , 
72+     emptyStringArr : {  type : 'string' ,  multiple : true ,  default : [ ]  } , 
73+     fullStringArr : {  type : 'string' ,  multiple : true ,  default : [ 'a' ,  'b' ]  } , 
74+     inputBoolArr : {  type : 'boolean' ,  multiple : true ,  default : [ false ,  true ,  false ]  } , 
75+     emptyBoolArr : {  type : 'boolean' ,  multiple : true ,  default : [ ]  } , 
76+     fullBoolArr : {  type : 'boolean' ,  multiple : true ,  default : [ false ,  true ,  false ]  } , 
7777  } ; 
7878  const  expected  =  {  values : {  __proto__ : null , 
7979                               inputStringArr : [ 'c' ,  'd' ] , 
@@ -88,12 +88,12 @@ test('defaultValue accepted input when multiple is true', (t) => {
8888  t . end ( ) ; 
8989} ) ; 
9090
91- test ( 'when defaultValue  is set, the option must be added as result' ,  ( t )  =>  { 
91+ test ( 'when default  is set, the option must be added as result' ,  ( t )  =>  { 
9292  const  args  =  [ ] ; 
9393  const  options  =  { 
94-     a : {  type : 'string' ,  defaultValue : 'HELLO'  } , 
95-     b : {  type : 'boolean' ,  defaultValue : false  } , 
96-     c : {  type : 'boolean' ,  defaultValue : true  } 
94+     a : {  type : 'string' ,  default : 'HELLO'  } , 
95+     b : {  type : 'boolean' ,  default : false  } , 
96+     c : {  type : 'boolean' ,  default : true  } 
9797  } ; 
9898  const  expected  =  {  values : {  __proto__ : null ,  a : 'HELLO' ,  b : false ,  c : true  } ,  positionals : [ ]  } ; 
9999
@@ -103,12 +103,12 @@ test('when defaultValue is set, the option must be added as result', (t) => {
103103  t . end ( ) ; 
104104} ) ; 
105105
106- test ( 'when defaultValue  is set, the args value takes precedence' ,  ( t )  =>  { 
106+ test ( 'when default  is set, the args value takes precedence' ,  ( t )  =>  { 
107107  const  args  =  [ '--a' ,  'WORLD' ,  '--b' ,  '-c' ] ; 
108108  const  options  =  { 
109-     a : {  type : 'string' ,  defaultValue : 'HELLO'  } , 
110-     b : {  type : 'boolean' ,  defaultValue : false  } , 
111-     c : {  type : 'boolean' ,  defaultValue : true  } 
109+     a : {  type : 'string' ,  default : 'HELLO'  } , 
110+     b : {  type : 'boolean' ,  default : false  } , 
111+     c : {  type : 'boolean' ,  default : true  } 
112112  } ; 
113113  const  expected  =  {  values : {  __proto__ : null ,  a : 'WORLD' ,  b : true ,  c : true  } ,  positionals : [ ]  } ; 
114114
@@ -118,12 +118,12 @@ test('when defaultValue is set, the args value takes precedence', (t) => {
118118  t . end ( ) ; 
119119} ) ; 
120120
121- test ( 'tokens should not include the defaultValue  options' ,  ( t )  =>  { 
121+ test ( 'tokens should not include the default  options' ,  ( t )  =>  { 
122122  const  args  =  [ ] ; 
123123  const  options  =  { 
124-     a : {  type : 'string' ,  defaultValue : 'HELLO'  } , 
125-     b : {  type : 'boolean' ,  defaultValue : false  } , 
126-     c : {  type : 'boolean' ,  defaultValue : true  } 
124+     a : {  type : 'string' ,  default : 'HELLO'  } , 
125+     b : {  type : 'boolean' ,  default : false  } , 
126+     c : {  type : 'boolean' ,  default : true  } 
127127  } ; 
128128
129129  const  expectedTokens  =  [ ] ; 
@@ -133,13 +133,13 @@ test('tokens should not include the defaultValue options', (t) => {
133133  t . end ( ) ; 
134134} ) ; 
135135
136- test ( 'tokens:true should not include the defaultValue  options after the args input' ,  ( t )  =>  { 
136+ test ( 'tokens:true should not include the default  options after the args input' ,  ( t )  =>  { 
137137  const  args  =  [ '--z' ,  'zero' ,  'positional-item' ] ; 
138138  const  options  =  { 
139139    z : {  type : 'string'  } , 
140-     a : {  type : 'string' ,  defaultValue : 'HELLO'  } , 
141-     b : {  type : 'boolean' ,  defaultValue : false  } , 
142-     c : {  type : 'boolean' ,  defaultValue : true  } 
140+     a : {  type : 'string' ,  default : 'HELLO'  } , 
141+     b : {  type : 'boolean' ,  default : false  } , 
142+     c : {  type : 'boolean' ,  default : true  } 
143143  } ; 
144144
145145  const  expectedTokens  =  [ 
@@ -157,7 +157,7 @@ test('proto as default value must be ignored', (t) => {
157157  const  options  =  Object . create ( null ) ; 
158158
159159  // eslint-disable-next-line no-proto 
160-   options . __proto__  =  {  type : 'string' ,  defaultValue : 'HELLO'  } ; 
160+   options . __proto__  =  {  type : 'string' ,  default : 'HELLO'  } ; 
161161
162162  const  result  =  parseArgs ( {  args,  options,  allowPositionals : true  } ) ; 
163163  const  expected  =  {  values : {  __proto__ : null  } ,  positionals : [ ]  } ; 
@@ -168,10 +168,10 @@ test('proto as default value must be ignored', (t) => {
168168
169169test ( 'multiple as false should expect a String and not an array' ,  ( t )  =>  { 
170170  const  args  =  [ ] ; 
171-   const  options  =  {  alpha : {  type : 'string' ,  multiple : false ,  defaultValue : 42  }  } ; 
171+   const  options  =  {  alpha : {  type : 'string' ,  multiple : false ,  default : 42  }  } ; 
172172  t . throws ( ( )  =>  { 
173173    parseArgs ( {  args,  options } ) ; 
174-   } ,  / a l p h a \. d e f a u l t V a l u e   m u s t   b e   S t r i n g / 
174+   } ,  / a l p h a \. d e f a u l t   m u s t   b e   S t r i n g / 
175175  ) ; 
176176  t . end ( ) ; 
177177} ) ; 
0 commit comments