Skip to content

Commit 923a3b1

Browse files
committed
tests
1 parent d9d6fbd commit 923a3b1

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

test/yargs-parser.js

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ describe('yargs-parser', function () {
11081108
})
11091109
})
11101110

1111-
describe('with implied false default', function () {
1111+
describe('without any default value', function () {
11121112
var opts = null
11131113

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

1128-
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

@@ -2321,7 +2321,7 @@ describe('yargs-parser', function () {
23212321
describe('type=number', function () {
23222322
it('[-x 1 -x 2 -x 3] => 3', function () {
23232323
var parsed = parser('-x 1 -x 2 -x 3', {
2324-
number: 'x',
2324+
number: ['x'],
23252325
configuration: {
23262326
'duplicate-arguments-array': false,
23272327
'flatten-duplicate-arrays': false
@@ -2330,6 +2330,18 @@ describe('yargs-parser', function () {
23302330
parsed['x'].should.deep.equal(3)
23312331
})
23322332
})
2333+
describe('type=boolean', function () {
2334+
it('[-x true -x true -x false] => false', function () {
2335+
var parsed = parser('-x true -x true -x false', {
2336+
boolean: ['x'],
2337+
configuration: {
2338+
'duplicate-arguments-array': false,
2339+
'flatten-duplicate-arrays': false
2340+
}
2341+
})
2342+
parsed['x'].should.deep.equal(false)
2343+
})
2344+
})
23332345
})
23342346
describe('duplicate=false, flatten=true,', function () {
23352347
describe('type=array', function () {
@@ -2357,7 +2369,7 @@ describe('yargs-parser', function () {
23572369
describe('type=number', function () {
23582370
it('[-x 1 -x 2 -x 3] => 3', function () {
23592371
var parsed = parser('-x 1 -x 2 -x 3', {
2360-
number: 'x',
2372+
number: ['x'],
23612373
configuration: {
23622374
'duplicate-arguments-array': false,
23632375
'flatten-duplicate-arrays': true
@@ -2366,6 +2378,18 @@ describe('yargs-parser', function () {
23662378
parsed['x'].should.deep.equal(3)
23672379
})
23682380
})
2381+
describe('type=boolean', function () {
2382+
it('[-x true -x true -x false] => false', function () {
2383+
var parsed = parser('-x true -x true -x false', {
2384+
boolean: ['x'],
2385+
configuration: {
2386+
'duplicate-arguments-array': false,
2387+
'flatten-duplicate-arrays': true
2388+
}
2389+
})
2390+
parsed['x'].should.deep.equal(false)
2391+
})
2392+
})
23692393
})
23702394
describe('duplicate=true, flatten=true,', function () {
23712395
describe('type=array', function () {
@@ -2393,7 +2417,7 @@ describe('yargs-parser', function () {
23932417
describe('type=number', function () {
23942418
it('[-x 1 -x 2 -x 3] => [1, 2, 3]', function () {
23952419
var parsed = parser('-x 1 -x 2 -x 3', {
2396-
number: 'x',
2420+
number: ['x'],
23972421
configuration: {
23982422
'duplicate-arguments-array': true,
23992423
'flatten-duplicate-arrays': true
@@ -2402,6 +2426,18 @@ describe('yargs-parser', function () {
24022426
parsed['x'].should.deep.equal([1, 2, 3])
24032427
})
24042428
})
2429+
describe('type=boolean', function () {
2430+
it('[-x true -x true -x false] => [true, true, false]', function () {
2431+
var parsed = parser('-x true -x true -x false', {
2432+
boolean: ['x'],
2433+
configuration: {
2434+
'duplicate-arguments-array': true,
2435+
'flatten-duplicate-arrays': true
2436+
}
2437+
})
2438+
parsed['x'].should.deep.equal([true, true, false])
2439+
})
2440+
})
24052441
})
24062442
describe('duplicate=true, flatten=false,', function () {
24072443
describe('type=array', function () {
@@ -2429,7 +2465,7 @@ describe('yargs-parser', function () {
24292465
describe('type=number', function () {
24302466
it('[-x 1 -x 2 -x 3] => [1, 2, 3]', function () {
24312467
var parsed = parser('-x 1 -x 2 -x 3', {
2432-
number: 'x',
2468+
number: ['x'],
24332469
configuration: {
24342470
'duplicate-arguments-array': true,
24352471
'flatten-duplicate-arrays': false
@@ -2438,6 +2474,18 @@ describe('yargs-parser', function () {
24382474
parsed['x'].should.deep.equal([1, 2, 3])
24392475
})
24402476
})
2477+
describe('type=boolean', function () {
2478+
it('[-x true -x true -x false] => [true, true, false]', function () {
2479+
var parsed = parser('-x true -x true -x false', {
2480+
boolean: ['x'],
2481+
configuration: {
2482+
'duplicate-arguments-array': true,
2483+
'flatten-duplicate-arrays': false
2484+
}
2485+
})
2486+
parsed['x'].should.deep.equal([true, true, false])
2487+
})
2488+
})
24412489
})
24422490
})
24432491

0 commit comments

Comments
 (0)