Skip to content
Myr

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 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–24why, 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; });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 back
25program.commands[0]._noHelp.should.be.false();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

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

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

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

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 28–30why, one step back
28program.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 back
31program.commands[3]._noHelp.should.be.true();

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 32–33why, one step back
32program.commands[4].name().should.equal('help');
33

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

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

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 35–37why, one step back
35sinon.stub(process.stdout, 'write');
36program.outputHelp();37

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

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

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

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

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

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

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

lines 44–46why, one step back
44 ' Commands:',
45 '',46 ' mycommand [options] this is my command',

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

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

Merge pull request #383 from tonylukasavage/nohelpRandall Koutnikbefore adoption2666457

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

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

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