Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jul 29, 2019
1 parent 590a263 commit 18da29e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/yargs-parser.js
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 18da29e

Please sign in to comment.