@@ -2874,4 +2874,71 @@ describe('yargs-parser', function () {
28742874 } )
28752875 argv . bar . should . equal ( 'hello' )
28762876 } )
2877+
2878+ describe ( 'stripping' , function ( ) {
2879+ it ( 'strip-dashed removes expected fields from argv' , function ( ) {
2880+ const argv = parser ( [ '--test-value' , '1' ] , {
2881+ number : [ 'test-value' ] ,
2882+ alias : {
2883+ 'test-value' : [ 'alt-test' ]
2884+ } ,
2885+ configuration : {
2886+ 'strip-dashed' : true
2887+ }
2888+ } )
2889+ argv . should . deep . equal ( {
2890+ _ : [ ] ,
2891+ 'testValue' : 1 ,
2892+ 'altTest' : 1
2893+ } )
2894+ } )
2895+
2896+ it ( 'strip-aliased removes expected fields from argv' , function ( ) {
2897+ const argv = parser ( [ '--test-value' , '1' ] , {
2898+ number : [ 'test-value' ] ,
2899+ alias : {
2900+ 'test-value' : [ 'alt-test' ]
2901+ } ,
2902+ configuration : {
2903+ 'strip-aliased' : true
2904+ }
2905+ } )
2906+ argv . should . deep . equal ( {
2907+ _ : [ ] ,
2908+ 'test-value' : 1 ,
2909+ 'testValue' : 1
2910+ } )
2911+ } )
2912+
2913+ it ( 'strip-aliased and strip-dashed combined removes expected fields from argv' , function ( ) {
2914+ const argv = parser ( [ '--test-value' , '1' ] , {
2915+ number : [ 'test-value' ] ,
2916+ alias : {
2917+ 'test-value' : [ 'alt-test' ]
2918+ } ,
2919+ configuration : {
2920+ 'strip-aliased' : true ,
2921+ 'strip-dashed' : true
2922+ }
2923+ } )
2924+ argv . should . deep . equal ( {
2925+ _ : [ ] ,
2926+ 'testValue' : 1
2927+ } )
2928+ } )
2929+
2930+ it ( 'ignores strip-dashed if camel-case-expansion is disabled' , function ( ) {
2931+ const argv = parser ( [ '--test-value' , '1' ] , {
2932+ number : [ 'test-value' ] ,
2933+ configuration : {
2934+ 'camel-case-expansion' : false ,
2935+ 'strip-dashed' : true
2936+ }
2937+ } )
2938+ argv . should . deep . equal ( {
2939+ _ : [ ] ,
2940+ 'test-value' : 1
2941+ } )
2942+ } )
2943+ } )
28772944} )
0 commit comments