From 5b807d1116aa82aa630fcbfeb2708a4a07827934 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 13 Jan 2020 18:08:08 +0900 Subject: [PATCH] Add tests for help command --- test/cli/help.spec.js | 33 +++++++++++++++++++++++++++++++++ test/index.js | 1 + 2 files changed, 34 insertions(+) create mode 100644 test/cli/help.spec.js diff --git a/test/cli/help.spec.js b/test/cli/help.spec.js new file mode 100644 index 0000000000..1903adfa00 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/index.js b/test/index.js index da39d21087..37331aa2bc 100644 --- a/test/index.js +++ b/test/index.js @@ -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'); });