-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dominik Wilkowski <Hi@Dominik-Wilkowski.com>
- Loading branch information
1 parent
fb8cf32
commit 3e26171
Showing
1 changed file
with
31 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,40 @@ | ||
const generator = require('../../bin/generator'); | ||
const version = require('../../package.json').version; | ||
const child_process = require('child_process'); | ||
const path = require('path'); | ||
|
||
describe('create-keystone-app generator', () => { | ||
test('prints version', () => { | ||
expect(generator.version()).toBe(version); | ||
const cli = child_process.spawnSync('node', [ | ||
path.normalize(`${__dirname}/../../bin/cli.js`), | ||
'--version', | ||
]); | ||
expect(cli.stdout.toString().trim()).toBe(version); | ||
expect(cli.stderr.toString().trim()).toEqual(''); | ||
}); | ||
|
||
test('prints help', () => { | ||
expect(generator.help({})).toEqual(expect.stringContaining('Usage')); | ||
const cli = child_process.spawnSync('node', [ | ||
path.normalize(`${__dirname}/../../bin/cli.js`), | ||
'--help', | ||
]); | ||
expect(cli.stdout.toString().trim()).toEqual(expect.stringContaining('Usage')); | ||
expect(cli.stderr.toString().trim()).toEqual(''); | ||
}); | ||
|
||
test('prints error and help when used wrong', () => { | ||
const cli = child_process.spawnSync('node', [ | ||
path.normalize(`${__dirname}/../../bin/cli.js`), | ||
'-x', | ||
]); | ||
expect(cli.stderr.toString().trim()).toEqual( | ||
expect.stringContaining('Unknown or unexpected option') | ||
); | ||
expect(cli.stdout.toString().trim()).toEqual(expect.stringContaining('Usage')); | ||
}); | ||
|
||
test('prints help when no arguments given', () => { | ||
const cli = child_process.spawnSync('node', [path.normalize(`${__dirname}/../../bin/cli.js`)]); | ||
expect(cli.stdout.toString().trim()).toEqual(expect.stringContaining('Usage')); | ||
expect(cli.stderr.toString().trim()).toEqual(''); | ||
}); | ||
}); |