Skip to content

Commit

Permalink
feat: e2e tests (#52)
Browse files Browse the repository at this point in the history
* feat: e2e tests

* fix: fixed prettier issues

* chore: minor tweaks
  • Loading branch information
rishabhKalakoti authored and jamesgeorge007 committed Dec 10, 2019
1 parent 462e661 commit c16cba6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ test('shows up help message without any args', async t => {
t.snapshot(stdout);
});

test('shows version with arg -V', async t => {
const { stdout } = await execa(rootCommand, ['-V']);
const matchSnapshot = async (t, arg) => {
const { stdout } = await execa(rootCommand, [arg]);
t.snapshot(stdout);
});
};

test('shows version with arg --version', async t => {
const { stdout } = await execa(rootCommand, ['--version']);
t.snapshot(stdout);
test('shows version with arg --version', matchSnapshot, '--version');
test('shows version with arg -V', matchSnapshot, '-V');
test('shows help with arg -h', matchSnapshot, '-h');
test('shows help with arg --help', matchSnapshot, '--help');
test('shows command usage with unknown command', matchSnapshot, 'junkcmd');

test('rejects promise due to error with arg -a', async t => {
const { stderr } = await execa(rootCommand, ['-a'], { reject: false });
t.snapshot(stderr);
});
61 changes: 61 additions & 0 deletions test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,64 @@ Generated by [AVA](https://ava.li).
> Snapshot 1
'1.2.6'

## rejects promise due to error with arg -a

> Snapshot 1
`error: unknown option `-a'␊
`

## shows command usage with unknown command

> Snapshot 1
`Usage: teachcode <command> [options]␊
Options:␊
-V, --version output the version number␊
-h, --help output usage information␊
Commands:␊
init Initialize challenges␊
submit Submits current task␊
fetchtask <key> Fetches any task as per the key supplied␊
showkeys Shows keys of all the completed tasks␊
showcommands Shows all commands available␊
Unknown command junkcmd.␊
`

## shows help with arg --help

> Snapshot 1
`Usage: teachcode <command> [options]␊
Options:␊
-V, --version output the version number␊
-h, --help output usage information␊
Commands:␊
init Initialize challenges␊
submit Submits current task␊
fetchtask <key> Fetches any task as per the key supplied␊
showkeys Shows keys of all the completed tasks␊
showcommands Shows all commands available`

## shows help with arg -h

> Snapshot 1
`Usage: teachcode <command> [options]␊
Options:␊
-V, --version output the version number␊
-h, --help output usage information␊
Commands:␊
init Initialize challenges␊
submit Submits current task␊
fetchtask <key> Fetches any task as per the key supplied␊
showkeys Shows keys of all the completed tasks␊
showcommands Shows all commands available`
Binary file modified test/snapshots/index.js.snap
Binary file not shown.

0 comments on commit c16cba6

Please sign in to comment.