Skip to content

Commit 6da3487

Browse files
committed
extend existing test
1 parent 6820d40 commit 6da3487

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/yargs-parser.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,17 @@ describe('yargs-parser', function () {
194194
parse.should.have.property('_').and.deep.equal(['aaatrueaaa', 'moo', 'aaafalseaaa'])
195195
})
196196

197-
it('should not use next value for boolean configured with zero narg', function () {
198-
var parse = parser(['--all', 'false'], {
199-
boolean: ['all'],
200-
narg: {
201-
all: 0
202-
}
203-
})
204-
parse.should.have.property('all', true).and.be.a('boolean')
205-
parse.should.have.property('_').and.deep.equal(['false'])
197+
it('should not use next value for boolean/number/string configured with zero narg', function () {
198+
var parse = parser(['--bool', 'false', '--nr', '7', '--str', 'foo'], {
199+
boolean: ['bool'],
200+
number: ['nr'],
201+
string: ['str'],
202+
narg: { bool: 0, nr: 0, str: 0 }
203+
})
204+
parse.should.have.property('bool', true).and.be.a('boolean')
205+
parse.should.have.property('nr', undefined).and.be.a('undefined')
206+
parse.should.have.property('str', '').and.be.a('string')
207+
parse.should.have.property('_').and.deep.equal(['false', 7, 'foo'])
206208
})
207209

208210
it('should allow defining options as boolean in groups', function () {

0 commit comments

Comments
 (0)