-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
test.command.helpInformation.custom.js
46 lines (37 loc) · 1.05 KB
/
test.command.helpInformation.custom.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
var program = require('../')
, sinon = require('sinon').sandbox.create()
, should = require('should');
sinon.stub(process, 'exit');
sinon.stub(process.stdout, 'write');
program.helpOption('-c, --HELP', 'custom help output');
program.command('somecommand');
program.command('anothercommand [options]');
var expectedHelpInformation = [
'Usage: [options] [command]',
'',
'Options:',
' -c, --HELP custom help output',
'',
'Commands:',
' somecommand',
' anothercommand [options]',
''
].join('\n');
program.helpInformation().should.equal(expectedHelpInformation);
// Test arguments
var expectedCommandHelpInformation = [
'Usage: test [options] [command]',
'',
'Options:',
' -c, --HELP custom help output',
'',
'Commands:',
' somecommand',
' anothercommand [options]',
''
].join('\n');
program.parse(['node', 'test', '--HELP']);
process.stdout.write.called.should.equal(true);
var output = process.stdout.write.args[0];
output[0].should.equal(expectedCommandHelpInformation);
sinon.restore();