@@ -2485,4 +2485,31 @@ describe('yargs-parser', function () {
24852485 } )
24862486 argv . foo . should . equal ( 9.39404959509494e+22 )
24872487 } )
2488+
2489+ // see: https://github.com/yargs/yargs-parser/issues/101
2490+ describe ( 'dot-notation array arguments combined with string arguments' , function ( ) {
2491+ it ( 'parses correctly when dot-notation argument is first' , function ( ) {
2492+ var argv = parser ( [ '--foo.bar' , 'baz' , '--foo' , 'bux' ] )
2493+ Array . isArray ( argv . foo ) . should . equal ( true )
2494+ argv . foo [ 0 ] . bar . should . equal ( 'baz' )
2495+ argv . foo [ 1 ] . should . equal ( 'bux' )
2496+ } )
2497+
2498+ it ( 'parses correctly when dot-notation argument is last' , function ( ) {
2499+ var argv = parser ( [ '--foo' , 'bux' , '--foo.bar' , 'baz' ] )
2500+ Array . isArray ( argv . foo ) . should . equal ( true )
2501+ argv . foo [ 0 ] . should . equal ( 'bux' )
2502+ argv . foo [ 1 ] . bar . should . equal ( 'baz' )
2503+ } )
2504+
2505+ it ( 'parses correctly when there are multiple dot-notation arguments' , function ( ) {
2506+ var argv = parser ( [ '--foo.first' , 'firstvalue' , '--foo' , 'bux' , '--foo.bar' , 'baz' , '--foo.bla' , 'banana' ] )
2507+ Array . isArray ( argv . foo ) . should . equal ( true )
2508+ argv . foo . length . should . equal ( 4 )
2509+ argv . foo [ 0 ] . first . should . equal ( 'firstvalue' )
2510+ argv . foo [ 1 ] . should . equal ( 'bux' )
2511+ argv . foo [ 2 ] . bar . should . equal ( 'baz' )
2512+ argv . foo [ 3 ] . bla . should . equal ( 'banana' )
2513+ } )
2514+ } )
24882515} )
0 commit comments