forked from rstackjs/rstack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.test.ts
More file actions
56 lines (46 loc) · 1.74 KB
/
Copy pathhelp.test.ts
File metadata and controls
56 lines (46 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { normalizeHelpOutput, test } from '#test-helpers';
import { hasHelpFlag } from '../../src/cli/help.ts';
test('detects help flags before the option terminator', ({ expect }) => {
expect(hasHelpFlag(['dev', '-h'])).toBe(true);
expect(hasHelpFlag(['dev', '--help'])).toBe(true);
expect(hasHelpFlag(['dev', '--', '--help'])).toBe(false);
expect(hasHelpFlag(['dev'])).toBe(false);
});
test('displays top-level help', ({ execCli, expect }) => {
expect(normalizeHelpOutput(execCli('--help'))).toMatchSnapshot();
});
for (const command of ['dev', 'build', 'preview', 'lint']) {
test(`displays ${command} help`, ({ execCli, expect }) => {
const output = execCli(`${command} --help`);
expect(execCli(`${command} -h`)).toBe(output);
expect(normalizeHelpOutput(output)).toMatchSnapshot();
});
}
for (const command of ['lib', 'lib build', 'lib inspect', 'lib mf-dev']) {
test(`displays ${command} help`, ({ execCli, expect }) => {
const output = execCli(`${command} --help`);
expect(execCli(`${command} -h`)).toBe(output);
expect(normalizeHelpOutput(output)).toMatchSnapshot();
});
}
for (const command of ['doc', 'doc build', 'doc preview', 'doc eject']) {
test(`displays ${command} help`, ({ execCli, expect }) => {
const output = execCli(`${command} --help`);
expect(execCli(`${command} -h`)).toBe(output);
expect(normalizeHelpOutput(output)).toMatchSnapshot();
});
}
for (const command of [
'test',
'test run',
'test watch',
'test list',
'test merge-reports',
'test init',
]) {
test(`displays ${command} help`, ({ execCli, expect }) => {
const output = execCli(`${command} --help`);
expect(execCli(`${command} -h`)).toBe(output);
expect(normalizeHelpOutput(output)).toMatchSnapshot();
});
}