Skip to content

Commit 18da29e

Browse files
committed
additional tests
1 parent 590a263 commit 18da29e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/yargs-parser.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,14 @@ describe('yargs-parser', function () {
14921492
result.should.have.property('b').and.deep.equal([])
14931493
})
14941494

1495+
it('should place default of argument in array, when default provided', function () {
1496+
var result = parser(['-b'], {
1497+
array: 'b',
1498+
default: { 'b': 33 }
1499+
})
1500+
result.should.have.property('b').and.deep.equal([33])
1501+
})
1502+
14951503
it('should place value of argument in array, when one argument provided', function () {
14961504
var result = parser(['-b', '33'], {
14971505
array: ['b']
@@ -1618,6 +1626,22 @@ describe('yargs-parser', function () {
16181626
result.should.have.property('x').that.is.an('array').and.to.deep.equal([true, false])
16191627
})
16201628

1629+
it('should respect type `boolean` without value for arrays', function () {
1630+
var result = parser(['-x', '-x'], {
1631+
array: [{ key: 'x', boolean: true }],
1632+
configuration: { 'flatten-duplicate-arrays': false }
1633+
})
1634+
result.x.should.deep.equal([[true], [true]])
1635+
})
1636+
1637+
it('should respect `boolean negation` for arrays', function () {
1638+
var result = parser(['--no-bool', '--no-bool'], {
1639+
array: [{ key: 'bool', boolean: true }],
1640+
configuration: { 'flatten-duplicate-arrays': false }
1641+
})
1642+
result.bool.should.deep.equal([[false], [false]])
1643+
})
1644+
16211645
it('should respect the type `number` option for arrays', function () {
16221646
var result = parser(['-x=5', '2'], {
16231647
array: [{ key: 'x', number: true }]

0 commit comments

Comments
 (0)