Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jun 17, 2019
1 parent fdd139a commit 3aa03f0
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
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 @@ -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 @@ -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 @@ -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 @@ -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 3aa03f0

Please sign in to comment.