-
-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathtest.js
27 lines (24 loc) · 754 Bytes
/
test.js
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
import childProcess from 'node:child_process';
import test from 'ava';
import {execa} from 'execa';
import {pEvent} from 'p-event';
test('main', async t => {
const subProcess = childProcess.spawn('./cli.js', {stdio: 'inherit'});
t.is(await pEvent(subProcess, 'close'), 0);
});
test('--json', async t => {
const {stdout} = await execa('./cli.js', ['--json']);
const parsed = JSON.parse(stdout);
t.truthy(parsed.ping);
t.truthy(parsed.upload);
t.truthy(parsed.download);
t.falsy(parsed.data);
});
test('--verbose --json', async t => {
const {stdout} = await execa('./cli.js', ['--verbose', '--json']);
const parsed = JSON.parse(stdout);
t.truthy(parsed.ping);
t.truthy(parsed.upload);
t.truthy(parsed.download);
t.truthy(parsed.data);
});