-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ed811e
commit f6a9d04
Showing
4 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
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', ['--version']); | ||
t.true(stdout.length > 0); | ||
const {stdout} = await execa('./cli.js', [fixture]); | ||
t.is(stdout, 'foofoo'); | ||
}); | ||
|
||
test('stdin', async t => { | ||
const {stdout} = await execa('./cli.js', { | ||
input: '\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m', | ||
}); | ||
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, | ||
}); | ||
}); |