test.command.nohelp.js
This file
Path
test/test.command.nohelp.js
56 lines · 1.7 KiB · JavaScript
Last changed by
fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431
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–19why, 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; });19fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431
lines 20–21why, one step back20program.command('hiddencommandwithoutdescription [options]', { noHelp: true });21Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 22–23why, one step back22program.parse(['node', 'test']);23fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431
line 24why, one step back24program.name.should.be.a.Function();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 25–26why, one step back25program.name().should.equal('test');26program.commands[0].name().should.equal('mycommand');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 27why, one step back27program.commands[0]._noHelp.should.be.false();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 28why, one step back28program.commands[1].name().should.equal('anothercommand');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 29why, one step back29program.commands[1]._noHelp.should.be.false();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 30why, one step back30program.commands[2].name().should.equal('hiddencommand');fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431
line 31why, one step back31program.commands[2]._noHelp.should.be.true();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 32why, one step back32program.commands[3].name().should.equal('hideagain');Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 33why, one step back33program.commands[3]._noHelp.should.be.true();fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431
lines 34–38why, one step back34program.commands[4].name().should.equal('hiddencommandwithoutdescription');35program.commands[4]._noHelp.should.be.true();36program.commands[5].name().should.equal('help');3738Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 39why, one step back39Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 40why, one step back40sinon.restore();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 41–43why, one step back41sinon.stub(process.stdout, 'write');42program.outputHelp();43Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 44why, one step back44process.stdout.write.calledOnce.should.be.true();Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 45–48why, one step back45process.stdout.write.args.length.should.equal(1);4647var output = process.stdout.write.args[0];48Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 49why, one step back49var expect = [Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
lines 50–52why, one step back50 ' Commands:',51 '',52 ' mycommand [options] this is my command',Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
line 53why, one step back53 ' anothercommand [options]',Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457
line 54why, one step back54 ' help [cmd] display help for [cmd]'Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f
lines 55–56why, one step back55].join('\n');56output[0].indexOf(expect).should.not.be.equal(-1);