Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: e2e tests #52

Merged
merged 3 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.