Skip to content

Commit

Permalink
Add tests for help command
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonhoyoon committed Jan 13, 2020
1 parent e2c55d2 commit 5b807d1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/cli/help.spec.js
@@ -0,0 +1,33 @@
'use strict';

const path = require('path');
const { execCommand } = require('cli-testlab');

const cliPkg = require('../../package');
const KNEX = path.normalize(__dirname + '/../../bin/cli.js');

describe('help', () => {
it('Prints help', () => {
return execCommand(`node ${KNEX} --help`, {
expectedOutput: 'Usage',
});
});

it('Prints help using -h flag', () => {
return execCommand(`node ${KNEX} -h`, {
expectedOutput: 'Usage',
});
});

it('Prints help when no arguments are given', () => {
return execCommand(`node ${KNEX}`, {
expectedOutput: 'Usage',
});
});

it('Does not print help when argument is given', () => {
return execCommand(`node ${KNEX} -V`).then(({ stdout, _ }) => {
expect(stdout).to.not.include('Usage');
});
});
});
1 change: 1 addition & 0 deletions test/index.js
Expand Up @@ -93,4 +93,5 @@ describe('CLI tests', function() {
require('./cli/migrate-make.spec');
require('./cli/seed-make.spec');
require('./cli/version.spec');
require('./cli/help.spec');
});

0 comments on commit 5b807d1

Please sign in to comment.