@@ -92,7 +92,7 @@ describe('CLI API', () => {
92
92
command . parseAsync ( [ '--no-boolean' ] , { from : 'user' } ) ;
93
93
} ) ;
94
94
95
- it ( 'should make command with configs option' , async ( done ) => {
95
+ it ( 'should make command with configs boolean option' , async ( done ) => {
96
96
cli . program . commands = [ ] ;
97
97
98
98
const command = await cli . makeCommand (
@@ -101,7 +101,7 @@ describe('CLI API', () => {
101
101
} ,
102
102
[
103
103
{
104
- name : 'boolean' ,
104
+ name : 'configs- boolean' ,
105
105
configs : [
106
106
{
107
107
type : 'boolean' ,
@@ -111,13 +111,212 @@ describe('CLI API', () => {
111
111
} ,
112
112
] ,
113
113
( options ) => {
114
- expect ( options ) . toEqual ( { boolean : false } ) ;
114
+ expect ( options ) . toEqual ( { configsBoolean : false } ) ;
115
115
116
116
done ( ) ;
117
117
} ,
118
118
) ;
119
119
120
- command . parseAsync ( [ '--no-boolean' ] , { from : 'user' } ) ;
120
+ command . parseAsync ( [ '--no-configs-boolean' ] , { from : 'user' } ) ;
121
+ } ) ;
122
+
123
+ it ( 'should make command with configs number option' , async ( done ) => {
124
+ cli . program . commands = [ ] ;
125
+
126
+ const command = await cli . makeCommand (
127
+ {
128
+ name : 'command' ,
129
+ } ,
130
+ [
131
+ {
132
+ name : 'configs-number' ,
133
+ configs : [
134
+ {
135
+ type : 'number' ,
136
+ } ,
137
+ ] ,
138
+ description : 'description' ,
139
+ } ,
140
+ ] ,
141
+ ( options ) => {
142
+ expect ( options ) . toEqual ( { configsNumber : 42 } ) ;
143
+
144
+ done ( ) ;
145
+ } ,
146
+ ) ;
147
+
148
+ command . parseAsync ( [ '--configs-number' , '42' ] , { from : 'user' } ) ;
149
+ } ) ;
150
+
151
+ it ( 'should make command with configs string option' , async ( done ) => {
152
+ cli . program . commands = [ ] ;
153
+
154
+ const command = await cli . makeCommand (
155
+ {
156
+ name : 'command' ,
157
+ } ,
158
+ [
159
+ {
160
+ name : 'configs-string' ,
161
+ configs : [
162
+ {
163
+ type : 'string' ,
164
+ } ,
165
+ ] ,
166
+ description : 'description' ,
167
+ } ,
168
+ ] ,
169
+ ( options ) => {
170
+ expect ( options ) . toEqual ( { configsString : 'foo' } ) ;
171
+
172
+ done ( ) ;
173
+ } ,
174
+ ) ;
175
+
176
+ command . parseAsync ( [ '--configs-string' , 'foo' ] , { from : 'user' } ) ;
177
+ } ) ;
178
+
179
+ it ( 'should make command with configs path option' , async ( done ) => {
180
+ cli . program . commands = [ ] ;
181
+
182
+ const command = await cli . makeCommand (
183
+ {
184
+ name : 'command' ,
185
+ } ,
186
+ [
187
+ {
188
+ name : 'configs-path' ,
189
+ configs : [
190
+ {
191
+ type : 'path' ,
192
+ } ,
193
+ ] ,
194
+ description : 'description' ,
195
+ } ,
196
+ ] ,
197
+ ( options ) => {
198
+ expect ( options ) . toEqual ( { configsPath : '/root/foo' } ) ;
199
+
200
+ done ( ) ;
201
+ } ,
202
+ ) ;
203
+
204
+ command . parseAsync ( [ '--configs-path' , '/root/foo' ] , { from : 'user' } ) ;
205
+ } ) ;
206
+
207
+ it ( 'should make command with configs RegExp option' , async ( done ) => {
208
+ cli . program . commands = [ ] ;
209
+
210
+ const command = await cli . makeCommand (
211
+ {
212
+ name : 'command' ,
213
+ } ,
214
+ [
215
+ {
216
+ name : 'configs-regexp' ,
217
+ configs : [
218
+ {
219
+ type : 'RegExp' ,
220
+ } ,
221
+ ] ,
222
+ description : 'description' ,
223
+ } ,
224
+ ] ,
225
+ ( options ) => {
226
+ expect ( options ) . toEqual ( { configsRegexp : '\\w+' } ) ;
227
+
228
+ done ( ) ;
229
+ } ,
230
+ ) ;
231
+
232
+ command . parseAsync ( [ '--configs-regexp' , '\\w+' ] , { from : 'user' } ) ;
233
+ } ) ;
234
+
235
+ it ( 'should make command with configs enum/string option' , async ( done ) => {
236
+ cli . program . commands = [ ] ;
237
+
238
+ const command = await cli . makeCommand (
239
+ {
240
+ name : 'command' ,
241
+ } ,
242
+ [
243
+ {
244
+ name : 'enum-string' ,
245
+ configs : [
246
+ {
247
+ type : 'enum' ,
248
+ values : [ 'foo' ] ,
249
+ } ,
250
+ ] ,
251
+ description : 'description' ,
252
+ } ,
253
+ ] ,
254
+ ( options ) => {
255
+ expect ( options ) . toEqual ( { enumString : 'foo' } ) ;
256
+
257
+ done ( ) ;
258
+ } ,
259
+ ) ;
260
+
261
+ command . parseAsync ( [ '--enum-string' , 'foo' ] , { from : 'user' } ) ;
262
+ } ) ;
263
+
264
+ it ( 'should make command with configs enum/number option' , async ( done ) => {
265
+ cli . program . commands = [ ] ;
266
+
267
+ const command = await cli . makeCommand (
268
+ {
269
+ name : 'command' ,
270
+ } ,
271
+ [
272
+ {
273
+ name : 'enum-number' ,
274
+ configs : [
275
+ {
276
+ type : 'enum' ,
277
+ values : [ 42 ] ,
278
+ } ,
279
+ ] ,
280
+ description : 'description' ,
281
+ } ,
282
+ ] ,
283
+ ( options ) => {
284
+ expect ( options ) . toEqual ( { enumNumber : 42 } ) ;
285
+
286
+ done ( ) ;
287
+ } ,
288
+ ) ;
289
+
290
+ command . parseAsync ( [ '--enum-number' , '42' ] , { from : 'user' } ) ;
291
+ } ) ;
292
+
293
+ it ( 'should make command with configs enum/boolean option' , async ( done ) => {
294
+ cli . program . commands = [ ] ;
295
+
296
+ const command = await cli . makeCommand (
297
+ {
298
+ name : 'command' ,
299
+ } ,
300
+ [
301
+ {
302
+ name : 'enum-boolean' ,
303
+ configs : [
304
+ {
305
+ type : 'boolean' ,
306
+ values : [ false ] ,
307
+ } ,
308
+ ] ,
309
+ description : 'description' ,
310
+ } ,
311
+ ] ,
312
+ ( options ) => {
313
+ expect ( options ) . toEqual ( { enumBoolean : false } ) ;
314
+
315
+ done ( ) ;
316
+ } ,
317
+ ) ;
318
+
319
+ command . parseAsync ( [ '--no-enum-boolean' ] , { from : 'user' } ) ;
121
320
} ) ;
122
321
123
322
it ( 'should make command with Boolean option and negative value #2' , async ( done ) => {
0 commit comments