-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
25 lines (20 loc) · 663 Bytes
/
test.js
File metadata and controls
25 lines (20 loc) · 663 Bytes
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
import test from 'ava';
import {execa} from 'execa';
const fixture = '\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m';
test('main', async t => {
const {stdout} = await execa('./cli.js', [fixture]);
t.is(stdout, 'foofoo');
});
test('stdin', async t => {
const {stdout} = await execa('./cli.js', {input: fixture});
t.is(stdout, 'foofoo');
});
// NOTE: This test assumes AVA is run in a TTY environment
test('no input', async t => {
/** @type {import('execa').ExecaError} */
const error = await t.throwsAsync(execa('./cli.js', {stdin: 'inherit'}));
t.like(error, {
stderr: 'Input required',
exitCode: 1,
});
});