test.command.nohelp.js
This file
Path
test/test.command.nohelp.js
50 lines · 1.5 KiB · JavaScript
Last changed by
Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
History of this fileTake it
Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 1–4why, one step back1var program = require('../')2 , sinon = require('sinon').sandbox.create()3 , should = require('should');4Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
lines 5–7why, one step back5sinon.stub(process, 'exit');6sinon.stub(process.stdout, 'write');7Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 8–24why, one step back8program.command('mycommand [options]', 'this is my command');910program11 .command('anothercommand [options]')12 .action(function() { return; });1314program.command('hiddencommand [options]', 'you won\'t see me', { noHelp: true });1516program17 .command('hideagain [options]', null, { noHelp: true })18 .action(function() { return; });1920program.parse(['node', 'test']);2122program.name.should.be.a.Function;23program.name().should.equal('test');24program.commands[0].name().should.equal('mycommand');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 25why, one step back25program.commands[0]._noHelp.should.be.false();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 26why, one step back26program.commands[1].name().should.equal('anothercommand');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 27why, one step back27program.commands[1]._noHelp.should.be.false();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 28–30why, one step back28program.commands[2].name().should.equal('hiddencommand');29program.commands[2]._noHelp.should.be.true;30program.commands[3].name().should.equal('hideagain');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 31why, one step back31program.commands[3]._noHelp.should.be.true();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 32–33why, one step back32program.commands[4].name().should.equal('help');33Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 34why, one step back34sinon.restore();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 35–37why, one step back35sinon.stub(process.stdout, 'write');36program.outputHelp();37Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 38why, one step back38process.stdout.write.calledOnce.should.be.true();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 39–42why, one step back39process.stdout.write.args.length.should.equal(1);4041var output = process.stdout.write.args[0];42Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 43why, one step back43var expect = [Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 44–46why, one step back44 ' Commands:',45 '',46 ' mycommand [options] this is my command',Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 47why, one step back47 ' anothercommand [options]',Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 48why, one step back48 ' help [cmd] display help for [cmd]'Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
lines 49–50why, one step back49].join('\n');50output[0].indexOf(expect).should.not.be.equal(-1);