yargs 1.3.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../');
3
-
4
- describe('parse', function () {
5
-
6
- describe('defaults', function () {
7
- function checkNoArgs(argv, hasAlias) {
8
- it('should set defaults if no args', function() {
9
- var result = argv.parse([ ]);
10
- result.should.have.property('flag', true);
11
- if (hasAlias) {
12
- result.should.have.property('f', true);
13
- }
14
- });
15
- }
16
-
17
- function checkExtraArg(argv, hasAlias) {
18
- it('should set defaults if one extra arg', function() {
19
- var result = argv.parse([ 'extra' ]);
20
- result.should.have.property('flag', true);
21
- result.should.have.property('_').and.deep.equal(['extra']);
22
- if (hasAlias) {
23
- result.should.have.property('f', true);
24
- }
25
- });
26
- }
27
-
28
- function checkStringArg(argv, hasAlias) {
29
- it('should set defaults even if arg looks like a string', function() {
30
- var result = argv.parse([ '--flag', 'extra' ]);
31
- result.should.have.property('flag', true);
32
- result.should.have.property('_').and.deep.equal(['extra']);
33
- if (hasAlias) {
34
- result.should.have.property('f', true);
35
- }
36
- });
37
- }
38
-
39
- describe('for options with aliases', function () {
40
- var args = yargs().options({
41
- flag : {
42
- alias : 'f',
43
- default : true
44
- }
45
- });
46
-
47
- checkNoArgs(args, true);
48
- checkExtraArg(args, true);
49
- // This test case should fail, because we didn't specify that the
50
- // option is a boolean
51
- // checkStringArg(args, true);
52
- });
53
-
54
- describe('for typed options without aliases', function () {
55
- var args = yargs().options({
56
- flag : {
57
- type : 'boolean',
58
- default : true
59
- }
60
- });
61
-
62
- checkNoArgs(args);
63
- checkExtraArg(args);
64
- checkStringArg(args);
65
- });
66
-
67
- describe('for typed options with aliases', function () {
68
- var args = yargs().options({
69
- flag : {
70
- alias : 'f',
71
- type : 'boolean',
72
- default : true
73
- }
74
- });
75
-
76
- checkNoArgs(args, true);
77
- checkExtraArg(args, true);
78
- checkStringArg(args, true);
79
- });
80
- });
81
-
82
- });
@@ -1,21 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../');
3
-
4
- describe('parse', function () {
5
-
6
- describe('boolean modifier function', function () {
7
-
8
- it('should prevent yargs from sucking in the next option as the value of the first option', function () {
9
-
10
- // Arrange & Act
11
- var result = yargs().boolean('b').parse([ '-b', '123' ]);
12
-
13
- // Assert
14
- result.should.have.property('b').that.is.a('boolean').and.is.true;
15
- result.should.have.property('_').and.deep.equal([123]);
16
-
17
- });
18
-
19
- });
20
-
21
- });
package/test/short.js DELETED
@@ -1,20 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../');
3
-
4
- describe('short options', function () {
5
-
6
- it ('should set n to the numeric value 123', function () {
7
- var argv = yargs.parse([ '-n123' ]);
8
- should.exist(argv);
9
- argv.should.have.property('n', 123);
10
- });
11
-
12
- it ('should set option "1" to true, option "2" to true, and option "3" to numeric value 456', function () {
13
- var argv = yargs.parse([ '-123', '456' ]);
14
- should.exist(argv);
15
- argv.should.have.property('1', true);
16
- argv.should.have.property('2', true);
17
- argv.should.have.property('3', 456);
18
- });
19
-
20
- });