Skip to content

Commit

Permalink
Add a test case for calling --version in CLI (gatsbyjs#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
benstepp authored and KyleAMathews committed Apr 16, 2016
1 parent 49378e0 commit eae6af3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions test/integration/cli-returns-help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava'
import packageJson from '../../package.json'
import { gatsby } from '../support'

test('cli can be called and exits with 0', async t => {
Expand All @@ -17,3 +18,15 @@ test('cli returns help when called with unknown args', async t => {
const help = await gatsby(['--help'])
t.is(asdf.stdout, help.stdout)
})

test('cli does not return help when called with --version', async t => {
const version = await gatsby(['--version'])
const help = await gatsby(['--help'])
t.not(version.stdout, help.stdout)
})

test('cli returns the gatsby version when called with --version', async t => {
const versionCli = await gatsby(['--version'])
const versionPackage = packageJson.version
t.true(versionCli.stdout.indexOf(versionPackage) > -1)
})
4 changes: 2 additions & 2 deletions test/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export function spawn (command, args = [], options = {}) {
}

export function gatsby (args = [], options = {}) {
const spawnArguments = concat([gatsbyCli], args)
const spawnArguments = concat(['--', gatsbyCli], args)
return spawn(babel, spawnArguments, options)
}

export function build (fixturePath) {
const buildPath = path.resolve(fixturePath, 'public')
return remove(buildPath)
.then(() => spawn(babel, [gatsbyCli, 'build'], { cwd: fixturePath }))
.then(() => gatsby(['build'], { cwd: fixturePath }))
}

export function dom (filePath) {
Expand Down

0 comments on commit eae6af3

Please sign in to comment.