fix nohelp test
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by zhiyelee · committed by zhiyelee · parent 1559b3e · Browse files · 4 files·+18 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+18 added−15 removed
- tests:+12 added−12 removed
- other:+6 added−3 removed
Provenance
- Commit
8024df2- Tree
18ec5f8- Author
zhiyelee <zhiyelee@gmail.com>- Committer
zhiyelee <zhiyelee@gmail.com>- Parent
1559b3e
4 files changed+18 added−15 removed
modified:test/test.command.help.js-4 removed
6 unmodified lines78910111213146 unmodified lines
program.parse(['node', 'test']);
program.commandHelp().should.equal('\n Commands:\n\n mycommand [options]\n');
modified:test/test.command.nohelp.js+12 added-8 removed
12345678910119 unmodified lines2122232422252624272829302831323334353637343839404138424043444546444748464950var program = require('../') , sinon = require('sinon').sandbox.create() , should = require('should');
sinon.stub(process, 'exit');sinon.stub(process.stdout, 'write');
program.command('mycommand [options]', 'this is my command');
program .command('anothercommand [options]')9 unmodified lines
program.name.should.be.a.Function;program.name().should.equal('test');program.commands[0].name().should.equal('mycommand');program.commands[0]._noHelp.should.be.false;program.commands[0]._noHelp.should.be.false();program.commands[1].name().should.equal('anothercommand');program.commands[1]._noHelp.should.be.false;program.commands[1]._noHelp.should.be.false();program.commands[2].name().should.equal('hiddencommand');program.commands[2]._noHelp.should.be.true;program.commands[3].name().should.equal('hideagain');program.commands[3]._noHelp.should.be.true;program.commands[3]._noHelp.should.be.true();program.commands[4].name().should.equal('help');
sinon.restore();sinon.stub(process.stdout, 'write');program.outputHelp();
process.stdout.write.calledOnce.should.be.true;process.stdout.write.calledOnce.should.be.true();process.stdout.write.args.length.should.equal(1);
var output = process.stdout.write.args[0];sinon.restore();
output[0].should.containEql([var expect = [ ' Commands:', '', ' mycommand [options] this is my command', ' anothercommand [options] ', ' anothercommand [options]', ' help [cmd] display help for [cmd]'].join('\n'));].join('\n');output[0].indexOf(expect).should.not.be.equal(-1);modified:index.js+5 added-2 removed
1-1 /**2 * Module dependencies.3 */4 1009 unmodified lines1014 * @api public1015 */1016 1017 Command.prototype.outputHelp = function(cb) {1019- if (!cb) cb = function(passthru) { return passthru; } //supply benign callback if none specified1018+ if (!cb) {1019+ cb = function(passthru) {1020+ return passthru;1021+ }1022+ }1023 process.stdout.write(cb(this.helpInformation()));1024 this.emit('--help');1025 };1026 84 unmodified linesmodified:package.json+1 added-1 removed
13 unmodified lines1415161718181920212211 unmodified lines13 unmodified lines "url": "https://github.com/tj/commander.js.git" }, "devDependencies": { "should": ">= 0.0.1", "sinon": ">= 1.14.1" "sinon": "^1.17.1" }, "scripts": { "test": "make test" },11 unmodified lines