forked from tj/commander.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP resolves tj#649 switch to a modern test infrastructure
- Loading branch information
1 parent
e5d8f04
commit c9f9b07
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// converted from test/test.arguments.js | ||
var Command = require('../').Command | ||
, test = require('ava'); | ||
|
||
function createProgram(capture) { | ||
var program = new Command(); | ||
program | ||
.version('0.0.1') | ||
.arguments('<cmd> [env]') | ||
.action(function (cmd, env) { | ||
capture.cmdValue = cmd; | ||
capture.envValue = env; | ||
}) | ||
.option('-C, --chdir <path>', 'change the working directory') | ||
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf') | ||
.option('-T, --no-tests', 'ignore test hook'); | ||
return program; | ||
} | ||
|
||
test('option', (t) => { | ||
var capture = {}; | ||
var program = createProgram(capture); | ||
program.parse(['node', 'test', '--config', 'conf']); | ||
t.is(program.config, 'conf'); | ||
t.is(capture.cmdValue, undefined); | ||
t.is(capture.envValue, undefined); | ||
}) | ||
|
||
test('option and command', (t) => { | ||
var capture = {}; | ||
var program = createProgram(capture); | ||
program.parse(['node', 'test', '--config', 'conf1', 'setup', '--setup_mode', 'mode3', 'env1']); | ||
t.is(program.config, 'conf1'); | ||
t.is(capture.cmdValue, 'setup'); | ||
t.is(capture.envValue, 'env1'); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// converted from test/test.command.action.js | ||
var Command = require('../../').Command | ||
, test = require('ava'); | ||
|
||
test('command action', (t) => { | ||
var val; | ||
var program = new Command(); | ||
program | ||
.command('info [options]') | ||
.option('-C, --no-color', 'turn off color output') | ||
.action(function () { | ||
val = this.color; | ||
}); | ||
program.parse(['node', 'test', 'info', '-C']); | ||
t.is(program.commands.length, 1); | ||
t.false(program.commands[0].color); | ||
t.false(val); | ||
}) |