Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jun 15, 2019
1 parent d9d6fbd commit 923a3b1
Showing 1 changed file with 55 additions and 7 deletions.
62 changes: 55 additions & 7 deletions test/yargs-parser.js
Expand Up @@ -1108,7 +1108,7 @@ describe('yargs-parser', function () {
})
})

describe('with implied false default', function () {
describe('without any default value', function () {
var opts = null

beforeEach(function () {
Expand All @@ -1125,8 +1125,8 @@ describe('yargs-parser', function () {
parser(['--no-flag'], opts).flag.should.be.false // eslint-disable-line
})

it('should set false if no flag in arg', function () {
expect(parser([], opts).flag).to.be.undefined // eslint-disable-line
it('should not add property if no flag in arg', function () {
parser([''], opts).should.not.have.property('flag')
})
})

Expand Down Expand Up @@ -2321,7 +2321,7 @@ describe('yargs-parser', function () {
describe('type=number', function () {
it('[-x 1 -x 2 -x 3] => 3', function () {
var parsed = parser('-x 1 -x 2 -x 3', {
number: 'x',
number: ['x'],
configuration: {
'duplicate-arguments-array': false,
'flatten-duplicate-arrays': false
Expand All @@ -2330,6 +2330,18 @@ describe('yargs-parser', function () {
parsed['x'].should.deep.equal(3)
})
})
describe('type=boolean', function () {
it('[-x true -x true -x false] => false', function () {
var parsed = parser('-x true -x true -x false', {
boolean: ['x'],
configuration: {
'duplicate-arguments-array': false,
'flatten-duplicate-arrays': false
}
})
parsed['x'].should.deep.equal(false)
})
})
})
describe('duplicate=false, flatten=true,', function () {
describe('type=array', function () {
Expand Down Expand Up @@ -2357,7 +2369,7 @@ describe('yargs-parser', function () {
describe('type=number', function () {
it('[-x 1 -x 2 -x 3] => 3', function () {
var parsed = parser('-x 1 -x 2 -x 3', {
number: 'x',
number: ['x'],
configuration: {
'duplicate-arguments-array': false,
'flatten-duplicate-arrays': true
Expand All @@ -2366,6 +2378,18 @@ describe('yargs-parser', function () {
parsed['x'].should.deep.equal(3)
})
})
describe('type=boolean', function () {
it('[-x true -x true -x false] => false', function () {
var parsed = parser('-x true -x true -x false', {
boolean: ['x'],
configuration: {
'duplicate-arguments-array': false,
'flatten-duplicate-arrays': true
}
})
parsed['x'].should.deep.equal(false)
})
})
})
describe('duplicate=true, flatten=true,', function () {
describe('type=array', function () {
Expand Down Expand Up @@ -2393,7 +2417,7 @@ describe('yargs-parser', function () {
describe('type=number', function () {
it('[-x 1 -x 2 -x 3] => [1, 2, 3]', function () {
var parsed = parser('-x 1 -x 2 -x 3', {
number: 'x',
number: ['x'],
configuration: {
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': true
Expand All @@ -2402,6 +2426,18 @@ describe('yargs-parser', function () {
parsed['x'].should.deep.equal([1, 2, 3])
})
})
describe('type=boolean', function () {
it('[-x true -x true -x false] => [true, true, false]', function () {
var parsed = parser('-x true -x true -x false', {
boolean: ['x'],
configuration: {
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': true
}
})
parsed['x'].should.deep.equal([true, true, false])
})
})
})
describe('duplicate=true, flatten=false,', function () {
describe('type=array', function () {
Expand Down Expand Up @@ -2429,7 +2465,7 @@ describe('yargs-parser', function () {
describe('type=number', function () {
it('[-x 1 -x 2 -x 3] => [1, 2, 3]', function () {
var parsed = parser('-x 1 -x 2 -x 3', {
number: 'x',
number: ['x'],
configuration: {
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': false
Expand All @@ -2438,6 +2474,18 @@ describe('yargs-parser', function () {
parsed['x'].should.deep.equal([1, 2, 3])
})
})
describe('type=boolean', function () {
it('[-x true -x true -x false] => [true, true, false]', function () {
var parsed = parser('-x true -x true -x false', {
boolean: ['x'],
configuration: {
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': false
}
})
parsed['x'].should.deep.equal([true, true, false])
})
})
})
})

Expand Down

0 comments on commit 923a3b1

Please sign in to comment.