test.command.helpInformation.custom.js
This file
Path
test/test.command.helpInformation.custom.js
46 lines · 1.0 KiB · JavaScript
Last changed by
Merge branch 'idmontie-feature/issue-47-add-version-help-message-override' into release/3.0.0John Geebefore adoptionafb8156
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647var 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 argumentsvar 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();