Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Wilkowski <Hi@Dominik-Wilkowski.com>
  • Loading branch information
dominikwilkowski committed Mar 12, 2019
1 parent fb8cf32 commit 3e26171
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions packages/create-keystone-app/tests/bin/generator.test.js
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('');
});
});

0 comments on commit 3e26171

Please sign in to comment.