Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP resolves #649 switch to a modern test infrastructure #755

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"url": "https://github.com/tj/commander.js.git"
},
"scripts": {
"ava": "ava test-ava",
"test": "make test && npm run test-typings",
"test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json"
},
Expand All @@ -25,6 +26,7 @@
],
"dependencies": {},
"devDependencies": {
"ava": "^0.24.0",
"@types/node": "^7.0.48",
"should": "^11.2.1",
"sinon": "^2.4.1",
Expand Down
36 changes: 36 additions & 0 deletions test-ava/arguments.test.js
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');
})
18 changes: 18 additions & 0 deletions test-ava/command/action.test.js
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);
})