summaryrefslogtreecommitdiffstats
path: root/test.js
blob: 44cb500cdb8f353d07dddb491938335a3d7e4738 (plain)
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);
});