Skip to content
Myr

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 file

Take it

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 1–4why, one step back
1var program = require('../')
2 , sinon = require('sinon').sandbox.create()3 , should = require('should');4

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

lines 5–7why, one step back
5sinon.stub(process, 'exit');
6sinon.stub(process.stdout, 'write');7

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 8–19why, one step back
8program.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; });19

fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431

lines 20–21why, one step back
20program.command('hiddencommandwithoutdescription [options]', { noHelp: true });
21

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 22–23why, one step back
22program.parse(['node', 'test']);
23

fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431

line 24why, one step back
24program.name.should.be.a.Function();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 25–26why, one step back
25program.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 back
27program.commands[0]._noHelp.should.be.false();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

line 28why, one step back
28program.commands[1].name().should.equal('anothercommand');

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 29why, one step back
29program.commands[1]._noHelp.should.be.false();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

line 30why, one step back
30program.commands[2].name().should.equal('hiddencommand');

fix bug when description is add after command with options (#662)Antoine Moreauxbefore adoption5c74431

line 31why, one step back
31program.commands[2]._noHelp.should.be.true();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

line 32why, one step back
32program.commands[3].name().should.equal('hideagain');

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 33why, one step back
33program.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 back
34program.commands[4].name().should.equal('hiddencommandwithoutdescription');
35program.commands[4]._noHelp.should.be.true();36program.commands[5].name().should.equal('help');3738

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

line 39why, one step back
39

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 40why, one step back
40sinon.restore();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 41–43why, one step back
41sinon.stub(process.stdout, 'write');
42program.outputHelp();43

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 44why, one step back
44process.stdout.write.calledOnce.should.be.true();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 45–48why, one step back
45process.stdout.write.args.length.should.equal(1);
4647var output = process.stdout.write.args[0];48

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 49why, one step back
49var expect = [

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 50–52why, one step back
50 ' Commands:',
51 '',52 ' mycommand [options] this is my command',

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

line 53why, one step back
53 ' anothercommand [options]',

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

line 54why, one step back
54 ' help [cmd] display help for [cmd]'

Merge pull request #450 from zhiyelee/lizhiye/fixtestZhiye Libefore adoption272e22f

lines 55–56why, one step back
55].join('\n');
56output[0].indexOf(expect).should.not.be.equal(-1);