diff --git a/test/yargs-parser.js b/test/yargs-parser.js index a8628261..98f88924 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -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 () { @@ -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') }) }) @@ -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 () { @@ -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 () { @@ -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 () { @@ -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]) + }) + }) }) })