forked from stephenmathieson-boneyard/node-cpplint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse-options.js
85 lines (76 loc) · 1.89 KB
/
parse-options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* eslint-disable no-unused-vars */
'use strict';
var vows = require('vows');
var assert = require('assert');
var parseOptions = require('../lib/parse-options.js').parseOptions;
var suite = vows.describe('parse-options');
suite.addBatch({
'valid options': {
topic: function () {
parseOptions({
'verbosity': 1,
'counting': 'total',
'files': [
'/path/to/file1',
'/path/to/file2'
]
}, this.callback);
},
'should not error': function (err, result) {
assert.isNull(err);
},
'should pass an object': function (err, result) {
assert.isObject(result);
},
'should set correct values': function (err, result) {
assert.deepEqual(result.files, [
'/path/to/file1',
'/path/to/file2'
]);
assert.equal(result.verbosity, 1);
assert.equal(result.counting, 'total');
},
'should not pass in filters': function (err, result) {
assert.equal(result.filters, undefined);
}
},
'invalid options': {
topic: function () {
this.callback(null, parseOptions);
},
'should throw on bad verbosity level': function (err, fn) {
assert.throws(function () {
fn({
'verbosity': 1000,
'counting': 'total',
'files': [
'/path/to/file1',
'/path/to/file2'
]
});
});
},
'should throw on bad counting type': function (err, fn) {
assert.throws(function () {
fn({
'verbosity': 1,
'counting': 'cats',
'files': [
'/path/to/file1',
'/path/to/file2'
]
});
});
},
'should throw on bad files': function (err, fn) {
assert.throws(function () {
fn({
'verbosity': 1,
'counting': 'total',
'files': []
});
});
}
}
});
suite.export(module);