Skip to content

Commit

Permalink
fix #115
Browse files Browse the repository at this point in the history
  • Loading branch information
laggingreflex committed Jul 29, 2018
1 parent 6001454 commit f5a86de
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1532,29 +1532,29 @@ describe('yargs-parser', function () {

it('should eat camelCase switch with camelCase array option', function () {
var result = parser(['--someOption', '1', '2'], {
array: ['someOption']
})
array: ['someOption']
})
Array.isArray(result.someOption).should.equal(true)
result.someOption.should.deep.equal([1, 2])
})
it('should eat hyphenated switch with hyphenated array option', function () {
var result = parser(['--some-option', '1', '2'], {
array: ['some-option']
})
array: ['some-option']
})
Array.isArray(result['some-option']).should.equal(true)
result['some-option'].should.deep.equal([1, 2])
})
it('should eat camelCase switch with hyphenated array option', function () {
var result = parser(['--someOption', '1', '2'], {
array: ['some-option']
})
array: ['some-option']
})
Array.isArray(result['some-option']).should.equal(true)
result['some-option'].should.deep.equal([1, 2])
})
it('should eat hyphenated switch with camelCase array option', function () {
var result = parser(['--some-option', '1', '2'], {
array: ['someOption']
})
array: ['someOption']
})
Array.isArray(result['someOption']).should.equal(true)
result['someOption'].should.deep.equal([1, 2])
})
Expand Down Expand Up @@ -2117,6 +2117,16 @@ describe('yargs-parser', function () {

parsed['x'].should.deep.equal([['a', 'b'], ['c', 'd']])
})
it('nests duplicate array types of more than 2', function () {
var parsed = parser('-x a b -x c d -x e f -x g h', {
array: ['x'],
configuration: {
'flatten-duplicate-arrays': false
}
})

parsed['x'].should.deep.equal([['a', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h']])
})
it('doesn\'t nests single arrays', function () {
var parsed = parser('-x a b', {
array: ['x'],
Expand Down

0 comments on commit f5a86de

Please sign in to comment.