|
| 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