forked from bahmutov/simple-bin-help
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec.js
58 lines (52 loc) · 1.28 KB
/
spec.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
var la = require('lazy-ass')
var check = require('check-more-types')
/* global describe, it */
describe('simple bin help', function () {
var simpleHelp = require('..')
it('is a function', function () {
la(check.fn(simpleHelp))
})
it('is successful', function () {
var options = {
minArguments: 2
}
var cliArguments = ['foo', 'bar', 'baz']
la(simpleHelp(options, cliArguments))
})
it('checks number of arguments', function () {
var options = {
minArguments: 10,
noExit: true
}
var cliArguments = ['foo', 'bar', 'baz']
la(!simpleHelp(options, cliArguments))
})
it('calls provided method on fail', function () {
var called
function onFail () {
called = true
}
var options = {
minArguments: 1,
noExit: true,
onFail
}
var cliArguments = []
la(!simpleHelp(options, cliArguments), 'not enough arguments')
la(called, 'onFail called')
})
it('can show help with -h', function () {
var options = {
noExit: true
}
var cliArguments = ['-h']
la(simpleHelp(options, cliArguments))
})
it('can show help with --help', function () {
var options = {
noExit: true
}
var cliArguments = ['--help']
la(simpleHelp(options, cliArguments))
})
})