Skip to content
Myr

handle-invalid.js

This file

Path

test/stdio/handle-invalid.js

60 lines · 3.8 KiB · JavaScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

Split files into smaller ones (#976)ehmickybefore adoptiond7c6853

lines 1–3why, one step back
1import test from 'ava';
2import {execa, execaSync} from '../../index.js';3import {getStdio} from '../helpers/stdio.js';

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 4why, one step back
4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';

Split files into smaller ones (#976)ehmickybefore adoptiond7c6853

line 5why, one step back
5

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 6why, one step back
6setFixtureDirectory();

Split files into smaller ones (#976)ehmickybefore adoptiond7c6853

lines 7–60why, one step back
7
8const testEmptyArray = (t, fdNumber, optionName, execaMethod) => {9 t.throws(() => {10 execaMethod('empty.js', getStdio(fdNumber, []));11 }, {message: `The \`${optionName}\` option must not be an empty array.`});12};1314test('Cannot pass an empty array to stdin', testEmptyArray, 0, 'stdin', execa);15test('Cannot pass an empty array to stdout', testEmptyArray, 1, 'stdout', execa);16test('Cannot pass an empty array to stderr', testEmptyArray, 2, 'stderr', execa);17test('Cannot pass an empty array to stdio[*]', testEmptyArray, 3, 'stdio[3]', execa);18test('Cannot pass an empty array to stdin - sync', testEmptyArray, 0, 'stdin', execaSync);19test('Cannot pass an empty array to stdout - sync', testEmptyArray, 1, 'stdout', execaSync);20test('Cannot pass an empty array to stderr - sync', testEmptyArray, 2, 'stderr', execaSync);21test('Cannot pass an empty array to stdio[*] - sync', testEmptyArray, 3, 'stdio[3]', execaSync);2223const testInvalidValueSync = (t, fdNumber, stdioOption) => {24 const {message} = t.throws(() => {25 execaSync('empty.js', getStdio(fdNumber, stdioOption));26 });27 t.true(message.includes(`cannot be "${stdioOption}" with synchronous methods`));28};2930test('stdin cannot be "ipc", sync', testInvalidValueSync, 0, 'ipc');31test('stdout cannot be "ipc", sync', testInvalidValueSync, 1, 'ipc');32test('stderr cannot be "ipc", sync', testInvalidValueSync, 2, 'ipc');33test('stdio[*] cannot be "ipc", sync', testInvalidValueSync, 3, 'ipc');34test('stdin cannot be "overlapped", sync', testInvalidValueSync, 0, 'overlapped');35test('stdout cannot be "overlapped", sync', testInvalidValueSync, 1, 'overlapped');36test('stderr cannot be "overlapped", sync', testInvalidValueSync, 2, 'overlapped');37test('stdio[*] cannot be "overlapped", sync', testInvalidValueSync, 3, 'overlapped');3839const testInvalidArrayValue = (t, invalidStdio, fdNumber, execaMethod) => {40 t.throws(() => {41 execaMethod('empty.js', getStdio(fdNumber, ['pipe', invalidStdio]));42 }, {message: /must not include/});43};4445test('Cannot pass "ignore" and another value to stdin', testInvalidArrayValue, 'ignore', 0, execa);46test('Cannot pass "ignore" and another value to stdout', testInvalidArrayValue, 'ignore', 1, execa);47test('Cannot pass "ignore" and another value to stderr', testInvalidArrayValue, 'ignore', 2, execa);48test('Cannot pass "ignore" and another value to stdio[*]', testInvalidArrayValue, 'ignore', 3, execa);49test('Cannot pass "ignore" and another value to stdin - sync', testInvalidArrayValue, 'ignore', 0, execaSync);50test('Cannot pass "ignore" and another value to stdout - sync', testInvalidArrayValue, 'ignore', 1, execaSync);51test('Cannot pass "ignore" and another value to stderr - sync', testInvalidArrayValue, 'ignore', 2, execaSync);52test('Cannot pass "ignore" and another value to stdio[*] - sync', testInvalidArrayValue, 'ignore', 3, execaSync);53test('Cannot pass "ipc" and another value to stdin', testInvalidArrayValue, 'ipc', 0, execa);54test('Cannot pass "ipc" and another value to stdout', testInvalidArrayValue, 'ipc', 1, execa);55test('Cannot pass "ipc" and another value to stderr', testInvalidArrayValue, 'ipc', 2, execa);56test('Cannot pass "ipc" and another value to stdio[*]', testInvalidArrayValue, 'ipc', 3, execa);57test('Cannot pass "ipc" and another value to stdin - sync', testInvalidArrayValue, 'ipc', 0, execaSync);58test('Cannot pass "ipc" and another value to stdout - sync', testInvalidArrayValue, 'ipc', 1, execaSync);59test('Cannot pass "ipc" and another value to stderr - sync', testInvalidArrayValue, 'ipc', 2, execaSync);60test('Cannot pass "ipc" and another value to stdio[*] - sync', testInvalidArrayValue, 'ipc', 3, execaSync);