fix!: boolean now behaves the same as other array types (#184) · yargs/yargs-parser@17ca3bd

@@ -1108,7 +1108,7 @@ describe('yargs-parser', function () {

11081108

})

11091109

})

111011101111-

describe('with implied false default', function () {

1111+

describe('without any default value', function () {

11121112

var opts = null

1113111311141114

beforeEach(function () {

@@ -1125,8 +1125,8 @@ describe('yargs-parser', function () {

11251125

parser(['--no-flag'], opts).flag.should.be.false // eslint-disable-line

11261126

})

112711271128-

it('should set false if no flag in arg', function () {

1129-

expect(parser([], opts).flag).to.be.undefined // eslint-disable-line

1128+

it('should not add property if no flag in arg', function () {

1129+

parser([''], opts).should.not.have.property('flag')

11301130

})

11311131

})

11321132

@@ -2334,6 +2334,18 @@ describe('yargs-parser', function () {

23342334

parsed['x'].should.deep.equal(3)

23352335

})

23362336

})

2337+

describe('type=boolean', function () {

2338+

it('[-x true -x true -x false] => false', function () {

2339+

var parsed = parser('-x true -x true -x false', {

2340+

boolean: ['x'],

2341+

configuration: {

2342+

'duplicate-arguments-array': false,

2343+

'flatten-duplicate-arrays': false

2344+

}

2345+

})

2346+

parsed['x'].should.deep.equal(false)

2347+

})

2348+

})

23372349

})

23382350

describe('duplicate=false, flatten=true,', function () {

23392351

describe('type=array', function () {

@@ -2370,6 +2382,18 @@ describe('yargs-parser', function () {

23702382

parsed['x'].should.deep.equal(3)

23712383

})

23722384

})

2385+

describe('type=boolean', function () {

2386+

it('[-x true -x true -x false] => false', function () {

2387+

var parsed = parser('-x true -x true -x false', {

2388+

boolean: ['x'],

2389+

configuration: {

2390+

'duplicate-arguments-array': false,

2391+

'flatten-duplicate-arrays': true

2392+

}

2393+

})

2394+

parsed['x'].should.deep.equal(false)

2395+

})

2396+

})

23732397

})

23742398

describe('duplicate=true, flatten=true,', function () {

23752399

describe('type=array', function () {

@@ -2406,6 +2430,18 @@ describe('yargs-parser', function () {

24062430

parsed['x'].should.deep.equal([1, 2, 3])

24072431

})

24082432

})

2433+

describe('type=boolean', function () {

2434+

it('[-x true -x true -x false] => [true, true, false]', function () {

2435+

var parsed = parser('-x true -x true -x false', {

2436+

boolean: ['x'],

2437+

configuration: {

2438+

'duplicate-arguments-array': true,

2439+

'flatten-duplicate-arrays': true

2440+

}

2441+

})

2442+

parsed['x'].should.deep.equal([true, true, false])

2443+

})

2444+

})

24092445

})

24102446

describe('duplicate=true, flatten=false,', function () {

24112447

describe('type=array', function () {

@@ -2442,6 +2478,18 @@ describe('yargs-parser', function () {

24422478

parsed['x'].should.deep.equal([1, 2, 3])

24432479

})

24442480

})

2481+

describe('type=boolean', function () {

2482+

it('[-x true -x true -x false] => [true, true, false]', function () {

2483+

var parsed = parser('-x true -x true -x false', {

2484+

boolean: ['x'],

2485+

configuration: {

2486+

'duplicate-arguments-array': true,

2487+

'flatten-duplicate-arrays': false

2488+

}

2489+

})

2490+

parsed['x'].should.deep.equal([true, true, false])

2491+

})

2492+

})

24452493

})

24462494

})

24472495