Skip to content

Commit 08e7752

Browse files
refactor: move redundant logic to a helper method
1 parent 1df4da9 commit 08e7752

5 files changed

Lines changed: 77 additions & 17 deletions

File tree

e2e/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ test('shows up help message without any args', async t => {
1111
t.snapshot(stderr);
1212
});
1313

14-
test('shows up help message by passing in --help flag', async t => {
15-
const { stdout } = await execa(rootCommand, ['--help']);
16-
t.snapshot(stdout);
17-
});
14+
const matchSnapshot = async (t, arg) => {
15+
const { stdout } = await execa(rootCommand, [arg]);
16+
t.snapshot(stdout);
17+
};
1818

19-
test('shows up help message by passing in -h flag', async t => {
20-
const { stdout } = await execa(rootCommand, ['-h']);
21-
t.snapshot(stdout);
22-
});
19+
test('shows help with -h flag', matchSnapshot, '-h');
20+
test('shows help with --help flag', matchSnapshot, '--help');

e2e/index.js.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The actual snapshot is saved in `index.js.snap`.
44

55
Generated by [AVA](https://ava.li).
66

7-
## shows up help message by passing in --help flag
7+
## shows help with --help flag
88

99
> Snapshot 1
1010
@@ -26,7 +26,7 @@ Generated by [AVA](https://ava.li).
2626
Development:␊
2727
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
2828

29-
## shows up help message without any args
29+
## shows help with -h flag
3030

3131
> Snapshot 1
3232
@@ -46,11 +46,9 @@ Generated by [AVA](https://ava.li).
4646
https://docsifyjs.github.io/docsify-cli␊
4747
4848
Development:␊
49-
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊
50-
51-
[ERROR] 0 arguments passed. Please specify a command`
49+
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
5250

53-
## shows up help message by passing in -h flag
51+
## shows up help message without any args
5452

5553
> Snapshot 1
5654
@@ -70,4 +68,6 @@ Generated by [AVA](https://ava.li).
7068
https://docsifyjs.github.io/docsify-cli␊
7169
7270
Development:␊
73-
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
71+
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊
72+
73+
[ERROR] 0 arguments passed. Please specify a command`

e2e/index.js.snap

3 Bytes
Binary file not shown.

e2e/snapshots/index.js.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,73 @@
1-
# Snapshot report for `test/index.js`
1+
# Snapshot report for `e2e/index.js`
22

33
The actual snapshot is saved in `index.js.snap`.
44

55
Generated by [AVA](https://ava.li).
66

7+
## shows help with --help flag
8+
9+
> Snapshot 1
10+
11+
`Usage: docsify <init|serve> <path>␊
12+
13+
Commands:␊
14+
docsify init [path] Creates new docs␊
15+
docsify serve [path] Run local server to preview site.␊
16+
docsify start <path> Server for SSR␊
17+
18+
Global Options␊
19+
--help, -h Show help [boolean]␊
20+
--version, -v Show version number [boolean]␊
21+
22+
Documentation:␊
23+
https://docsifyjs.github.io/docsify␊
24+
https://docsifyjs.github.io/docsify-cli␊
25+
26+
Development:␊
27+
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
28+
29+
## shows help with -h flag
30+
31+
> Snapshot 1
32+
33+
`Usage: docsify <init|serve> <path>␊
34+
35+
Commands:␊
36+
docsify init [path] Creates new docs␊
37+
docsify serve [path] Run local server to preview site.␊
38+
docsify start <path> Server for SSR␊
39+
40+
Global Options␊
41+
--help, -h Show help [boolean]␊
42+
--version, -v Show version number [boolean]␊
43+
44+
Documentation:␊
45+
https://docsifyjs.github.io/docsify␊
46+
https://docsifyjs.github.io/docsify-cli␊
47+
48+
Development:␊
49+
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md`
50+
751
## shows up help message without any args
852

953
> Snapshot 1
1054
11-
''
55+
`Usage: docsify <init|serve> <path>␊
56+
57+
Commands:␊
58+
docsify init [path] Creates new docs␊
59+
docsify serve [path] Run local server to preview site.␊
60+
docsify start <path> Server for SSR␊
61+
62+
Global Options␊
63+
--help, -h Show help [boolean]␊
64+
--version, -v Show version number [boolean]␊
65+
66+
Documentation:␊
67+
https://docsifyjs.github.io/docsify␊
68+
https://docsifyjs.github.io/docsify-cli␊
69+
70+
Development:␊
71+
https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊
72+
73+
[ERROR] 0 arguments passed. Please specify a command`

e2e/snapshots/index.js.snap

394 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)