@@ -1108,7 +1108,7 @@ describe('yargs-parser', function () {
1108
1108
} )
1109
1109
} )
1110
1110
1111
- describe ( 'with implied false default' , function ( ) {
1111
+ describe ( 'without any default value ' , function ( ) {
1112
1112
var opts = null
1113
1113
1114
1114
beforeEach ( function ( ) {
@@ -1125,8 +1125,8 @@ describe('yargs-parser', function () {
1125
1125
parser ( [ '--no-flag' ] , opts ) . flag . should . be . false // eslint-disable-line
1126
1126
} )
1127
1127
1128
- it ( 'should set false if no flag in arg' , function ( ) {
1129
- expect ( parser ( [ ] , opts ) . flag ) . to . be . undefined // eslint-disable-line
1128
+ it ( 'should not add property if no flag in arg' , function ( ) {
1129
+ parser ( [ '' ] , opts ) . should . not . have . property ( 'flag' )
1130
1130
} )
1131
1131
} )
1132
1132
@@ -2321,7 +2321,7 @@ describe('yargs-parser', function () {
2321
2321
describe ( 'type=number' , function ( ) {
2322
2322
it ( '[-x 1 -x 2 -x 3] => 3' , function ( ) {
2323
2323
var parsed = parser ( '-x 1 -x 2 -x 3' , {
2324
- number : 'x' ,
2324
+ number : [ 'x' ] ,
2325
2325
configuration : {
2326
2326
'duplicate-arguments-array' : false ,
2327
2327
'flatten-duplicate-arrays' : false
@@ -2330,6 +2330,18 @@ describe('yargs-parser', function () {
2330
2330
parsed [ 'x' ] . should . deep . equal ( 3 )
2331
2331
} )
2332
2332
} )
2333
+ describe ( 'type=boolean' , function ( ) {
2334
+ it ( '[-x true -x true -x false] => false' , function ( ) {
2335
+ var parsed = parser ( '-x true -x true -x false' , {
2336
+ boolean : [ 'x' ] ,
2337
+ configuration : {
2338
+ 'duplicate-arguments-array' : false ,
2339
+ 'flatten-duplicate-arrays' : false
2340
+ }
2341
+ } )
2342
+ parsed [ 'x' ] . should . deep . equal ( false )
2343
+ } )
2344
+ } )
2333
2345
} )
2334
2346
describe ( 'duplicate=false, flatten=true,' , function ( ) {
2335
2347
describe ( 'type=array' , function ( ) {
@@ -2357,7 +2369,7 @@ describe('yargs-parser', function () {
2357
2369
describe ( 'type=number' , function ( ) {
2358
2370
it ( '[-x 1 -x 2 -x 3] => 3' , function ( ) {
2359
2371
var parsed = parser ( '-x 1 -x 2 -x 3' , {
2360
- number : 'x' ,
2372
+ number : [ 'x' ] ,
2361
2373
configuration : {
2362
2374
'duplicate-arguments-array' : false ,
2363
2375
'flatten-duplicate-arrays' : true
@@ -2366,6 +2378,18 @@ describe('yargs-parser', function () {
2366
2378
parsed [ 'x' ] . should . deep . equal ( 3 )
2367
2379
} )
2368
2380
} )
2381
+ describe ( 'type=boolean' , function ( ) {
2382
+ it ( '[-x true -x true -x false] => false' , function ( ) {
2383
+ var parsed = parser ( '-x true -x true -x false' , {
2384
+ boolean : [ 'x' ] ,
2385
+ configuration : {
2386
+ 'duplicate-arguments-array' : false ,
2387
+ 'flatten-duplicate-arrays' : true
2388
+ }
2389
+ } )
2390
+ parsed [ 'x' ] . should . deep . equal ( false )
2391
+ } )
2392
+ } )
2369
2393
} )
2370
2394
describe ( 'duplicate=true, flatten=true,' , function ( ) {
2371
2395
describe ( 'type=array' , function ( ) {
@@ -2393,7 +2417,7 @@ describe('yargs-parser', function () {
2393
2417
describe ( 'type=number' , function ( ) {
2394
2418
it ( '[-x 1 -x 2 -x 3] => [1, 2, 3]' , function ( ) {
2395
2419
var parsed = parser ( '-x 1 -x 2 -x 3' , {
2396
- number : 'x' ,
2420
+ number : [ 'x' ] ,
2397
2421
configuration : {
2398
2422
'duplicate-arguments-array' : true ,
2399
2423
'flatten-duplicate-arrays' : true
@@ -2402,6 +2426,18 @@ describe('yargs-parser', function () {
2402
2426
parsed [ 'x' ] . should . deep . equal ( [ 1 , 2 , 3 ] )
2403
2427
} )
2404
2428
} )
2429
+ describe ( 'type=boolean' , function ( ) {
2430
+ it ( '[-x true -x true -x false] => [true, true, false]' , function ( ) {
2431
+ var parsed = parser ( '-x true -x true -x false' , {
2432
+ boolean : [ 'x' ] ,
2433
+ configuration : {
2434
+ 'duplicate-arguments-array' : true ,
2435
+ 'flatten-duplicate-arrays' : true
2436
+ }
2437
+ } )
2438
+ parsed [ 'x' ] . should . deep . equal ( [ true , true , false ] )
2439
+ } )
2440
+ } )
2405
2441
} )
2406
2442
describe ( 'duplicate=true, flatten=false,' , function ( ) {
2407
2443
describe ( 'type=array' , function ( ) {
@@ -2429,7 +2465,7 @@ describe('yargs-parser', function () {
2429
2465
describe ( 'type=number' , function ( ) {
2430
2466
it ( '[-x 1 -x 2 -x 3] => [1, 2, 3]' , function ( ) {
2431
2467
var parsed = parser ( '-x 1 -x 2 -x 3' , {
2432
- number : 'x' ,
2468
+ number : [ 'x' ] ,
2433
2469
configuration : {
2434
2470
'duplicate-arguments-array' : true ,
2435
2471
'flatten-duplicate-arrays' : false
@@ -2438,6 +2474,18 @@ describe('yargs-parser', function () {
2438
2474
parsed [ 'x' ] . should . deep . equal ( [ 1 , 2 , 3 ] )
2439
2475
} )
2440
2476
} )
2477
+ describe ( 'type=boolean' , function ( ) {
2478
+ it ( '[-x true -x true -x false] => [true, true, false]' , function ( ) {
2479
+ var parsed = parser ( '-x true -x true -x false' , {
2480
+ boolean : [ 'x' ] ,
2481
+ configuration : {
2482
+ 'duplicate-arguments-array' : true ,
2483
+ 'flatten-duplicate-arrays' : false
2484
+ }
2485
+ } )
2486
+ parsed [ 'x' ] . should . deep . equal ( [ true , true , false ] )
2487
+ } )
2488
+ } )
2441
2489
} )
2442
2490
} )
2443
2491
0 commit comments