Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jul 26, 2019
1 parent 2f2ff5a commit 664a621
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,14 @@ describe('yargs-parser', function () {
result.should.have.property('b').and.deep.equal([])
})

it('should place default of argument in array, when default provided', function () {
var result = parser(['-b'], {
array: 'b',
default: { 'b': 33 }
})
result.should.have.property('b').and.deep.equal([33])
})

it('should place value of argument in array, when one argument provided', function () {
var result = parser(['-b', '33'], {
array: ['b']
Expand Down Expand Up @@ -1618,6 +1626,22 @@ describe('yargs-parser', function () {
result.should.have.property('x').that.is.an('array').and.to.deep.equal([true, false])
})

it('should respect type `boolean` without value for arrays', function () {
var result = parser(['-x', '-x'], {
array: [{ key: 'x', boolean: true }],
configuration: { 'flatten-duplicate-arrays': false }
})
result.x.should.deep.equal([[true], [true]])
})

it('should respect `boolean negation` for arrays', function () {
var result = parser(['--no-bool', '--no-bool'], {
array: [{ key: 'bool', boolean: true }],
configuration: { 'flatten-duplicate-arrays': false }
})
result.bool.should.deep.equal([[false], [false]])
})

it('should respect the type `number` option for arrays', function () {
var result = parser(['-x=5', '2'], {
array: [{ key: 'x', number: true }]
Expand Down

0 comments on commit 664a621

Please sign in to comment.