Skip to content

Commit

Permalink
Ensure no regression happens to #162
Browse files Browse the repository at this point in the history
  • Loading branch information
iilei committed Oct 6, 2018
1 parent 2bc2bd4 commit eb42a2a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,38 @@ describe('yargs-parser', function () {
result.should.have.property('x').that.is.an('array').and.to.deep.equal([true, false])
})

it('should eat non-hyphenated arguments until hyphenated option is hit - combined with coercion', function () {
var result = parser([
'-a=hello', 'world',
'-b', '33', '22',
'--foo', 'true', 'false',
'--bar=cat', 'dog'
], {
array: [
'a',
{ key: 'b', integer: true },
{ key: 'foo', boolean: true },
'bar'
]
})

Array.isArray(result.a).should.equal(true)
result.a.should.include('hello')
result.a.should.include('world')

Array.isArray(result.b).should.equal(true)
result.b.should.include(33)
result.b.should.include(22)

Array.isArray(result.foo).should.equal(true)
result.foo.should.include(true)
result.foo.should.include(false)

Array.isArray(result.bar).should.equal(true)
result.bar.should.include('cat')
result.bar.should.include('dog')
})

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 eb42a2a

Please sign in to comment.