Skip to content

Commit b7c8fcc

Browse files
Jake ChampionJakeChampion
authored andcommitted
add test for --help and -h flags
1 parent 20081e6 commit b7c8fcc

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

integration-tests/cli/help.test.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@gmrchk/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('--help should return help on stdout and zero exit code', async function (t) {
8+
const { execute, cleanup } = await prepareEnvironment();
9+
const { code, stdout, stderr } = await execute('node',`${cli} --help`);
10+
11+
t.is(code, 0);
12+
t.alike(stdout, [
13+
'js-compute-runtime 0.5.4',
14+
'USAGE:',
15+
'js-compute-runtime [FLAGS] [OPTIONS] [ARGS]',
16+
'FLAGS:',
17+
'-h, --help Prints help information',
18+
'-V, --version Prints version information',
19+
'OPTIONS:',
20+
'--engine-wasm <engine-wasm> The JS engine Wasm file path',
21+
'ARGS:',
22+
'<input> The input JS script\'s file path [default: bin/index.js]',
23+
'<output> The file path to write the output Wasm module to [default: bin/main.wasm]'
24+
])
25+
t.alike(stderr, [])
26+
27+
await cleanup();
28+
});
29+
30+
test('-h should return help on stdout and zero exit code', async function (t) {
31+
const { execute, cleanup } = await prepareEnvironment();
32+
t.teardown(async function () {
33+
await cleanup();
34+
});
35+
const { code, stdout, stderr } = await execute('node',`${cli} -h`);
36+
37+
t.is(code, 0);
38+
t.alike(stdout, [
39+
'js-compute-runtime 0.5.4',
40+
'USAGE:',
41+
'js-compute-runtime [FLAGS] [OPTIONS] [ARGS]',
42+
'FLAGS:',
43+
'-h, --help Prints help information',
44+
'-V, --version Prints version information',
45+
'OPTIONS:',
46+
'--engine-wasm <engine-wasm> The JS engine Wasm file path',
47+
'ARGS:',
48+
'<input> The input JS script\'s file path [default: bin/index.js]',
49+
'<output> The file path to write the output Wasm module to [default: bin/main.wasm]'
50+
])
51+
t.alike(stderr, [])
52+
});

0 commit comments

Comments
 (0)