@@ -1260,6 +1260,46 @@ describe('yargs-parser', function () {
12601260 } )
12611261 } )
12621262
1263+ describe ( 'option --' , function ( ) {
1264+ describe ( 'when it is not defined' , function ( ) {
1265+ it ( 'should not initialize the \'--\' array' , function ( ) {
1266+ var result = parser ( [
1267+ 'bare' ,
1268+ '--' , '-h' , 'eek' , '--'
1269+ ] )
1270+ result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , '-h' , 'eek' , '--' ] )
1271+ result . should . not . have . property ( '--' )
1272+ } )
1273+ } )
1274+
1275+ describe ( 'when it is defined' , function ( ) {
1276+ it ( 'should set bare flags to \'_\' array and non-flags to \'--\' array' , function ( ) {
1277+ var result = parser ( [
1278+ '--name=meowmers' , 'bare' , '-cats' , 'woo' , 'moxy' ,
1279+ '-h' , 'awesome' , '--multi=quux' ,
1280+ '--key' , 'value' ,
1281+ '-b' , '--bool' , '--no-meep' , '--multi=baz' ,
1282+ '--' , '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek'
1283+ ] , {
1284+ '--' : true
1285+ } )
1286+ result . should . have . property ( 'c' , true )
1287+ result . should . have . property ( 'a' , true )
1288+ result . should . have . property ( 't' , true )
1289+ result . should . have . property ( 's' , 'woo' )
1290+ result . should . have . property ( 'h' , 'awesome' )
1291+ result . should . have . property ( 'b' , true )
1292+ result . should . have . property ( 'bool' , true )
1293+ result . should . have . property ( 'key' , 'value' )
1294+ result . should . have . property ( 'multi' ) . and . deep . equal ( [ 'quux' , 'baz' ] )
1295+ result . should . have . property ( 'meep' , false )
1296+ result . should . have . property ( 'name' , 'meowmers' )
1297+ result . should . have . property ( '_' ) . and . deep . equal ( [ 'bare' , 'moxy' ] )
1298+ result . should . have . property ( '--' ) . and . deep . equal ( [ '--not-a-flag' , '-' , '-h' , '-multi' , '--' , 'eek' ] )
1299+ } )
1300+ } )
1301+ } )
1302+
12631303 describe ( 'count' , function ( ) {
12641304 it ( 'should count the number of times a boolean is present' , function ( ) {
12651305 var parsed
0 commit comments