@@ -233,6 +233,43 @@ describe('validation tests', function () {
233233 argv . _ [ 0 ] . should . equal ( 'koala' )
234234 } )
235235
236+ // addresses: https://github.com/yargs/yargs/issues/791
237+ it ( 'should recognize context variables in strict mode' , function ( done ) {
238+ yargs ( )
239+ . command ( 'foo <y>' )
240+ . strict ( )
241+ . parse ( 'foo 99' , { x : 33 } , function ( err , argv , output ) {
242+ expect ( err ) . to . equal ( null )
243+ expect ( output ) . to . equal ( '' )
244+ argv . y . should . equal ( 99 )
245+ argv . x . should . equal ( 33 )
246+ argv . _ . should . include ( 'foo' )
247+ return done ( )
248+ } )
249+ } )
250+
251+ // addresses: https://github.com/yargs/yargs/issues/791
252+ it ( 'should recognize context variables in strict mode, when running sub-commands' , function ( done ) {
253+ yargs ( )
254+ . command ( 'request' , 'request command' , function ( yargs ) {
255+ yargs
256+ . command ( 'get' , 'sub-command' )
257+ . option ( 'y' , {
258+ describe : 'y inner option'
259+ } )
260+ } )
261+ . strict ( )
262+ . parse ( 'request get --y=22' , { x : 33 } , function ( err , argv , output ) {
263+ expect ( err ) . to . equal ( null )
264+ expect ( output ) . to . equal ( '' )
265+ argv . y . should . equal ( 22 )
266+ argv . x . should . equal ( 33 )
267+ argv . _ . should . include ( 'request' )
268+ argv . _ . should . include ( 'get' )
269+ return done ( )
270+ } )
271+ } )
272+
236273 it ( 'fails when a required argument is missing' , function ( done ) {
237274 yargs ( '-w 10 marsupial' )
238275 . demand ( 1 , [ 'w' , 'b' ] )
0 commit comments