Skip to content
Myr

input.js

This file

Path

test/stdio/input.js

43 lines · 2.5 KiB · JavaScript

Last changed by

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

History of this file

Take it

Validate `input` option's type (#668)ehmickybefore adoption65742c6

line 1why, one step back
1import {Writable} from 'node:stream';

Refactor tests (#628)ehmickybefore adoption30ecc81

line 2why, one step back
2import test from 'ava';

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 3why, one step back
3import {execa, execaSync} from '../../index.js';

Refactor tests (#628)ehmickybefore adoption30ecc81

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

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 5why, one step back
5import {runExeca, runExecaSync, runScript, runScriptSync} from '../helpers/run.js';

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

line 6why, one step back
6import {foobarUint8Array, foobarBuffer, foobarArrayBuffer, foobarUint16Array, foobarDataView} from '../helpers/input.js';

Refactor tests (#628)ehmickybefore adoption30ecc81

lines 7–14why, one step back
7
8setFixtureDir();910const testInput = async (t, input, execaMethod) => {11 const {stdout} = await execaMethod('stdin.js', {input});12 t.is(stdout, 'foobar');13};14

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 15why, one step back
15test('input option can be a String', testInput, 'foobar', runExeca);

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

line 16why, one step back
16test('input option can be a Uint8Array', testInput, foobarUint8Array, runExeca);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 17why, one step back
17test('input option can be a String - sync', testInput, 'foobar', runExecaSync);

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

line 18why, one step back
18test('input option can be a Uint8Array - sync', testInput, foobarUint8Array, runExecaSync);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 19–20why, one step back
19test('input option can be used with $', testInput, 'foobar', runScript);
20test('input option can be used with $.sync', testInput, 'foobar', runScriptSync);

Refactor tests (#628)ehmickybefore adoption30ecc81

line 21why, one step back
21

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 22–23why, one step back
22const testInvalidInput = async (t, input, execaMethod) => {
23 t.throws(() => {

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 24why, one step back
24 execaMethod('empty.js', {input});

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 25–27why, one step back
25 }, {message: /a string, a Uint8Array/});
26};27

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

lines 28–31why, one step back
28test('input option cannot be a Buffer', testInvalidInput, foobarBuffer, execa);
29test('input option cannot be an ArrayBuffer', testInvalidInput, foobarArrayBuffer, execa);30test('input option cannot be a DataView', testInvalidInput, foobarDataView, execa);31test('input option cannot be a Uint16Array', testInvalidInput, foobarUint16Array, execa);

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 32–35why, one step back
32test('input option cannot be 0', testInvalidInput, 0, execa);
33test('input option cannot be false', testInvalidInput, false, execa);34test('input option cannot be null', testInvalidInput, null, execa);35test('input option cannot be a non-Readable stream', testInvalidInput, new Writable(), execa);

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

lines 36–39why, one step back
36test('input option cannot be a Buffer - sync', testInvalidInput, foobarBuffer, execaSync);
37test('input option cannot be an ArrayBuffer - sync', testInvalidInput, foobarArrayBuffer, execaSync);38test('input option cannot be a DataView - sync', testInvalidInput, foobarDataView, execaSync);39test('input option cannot be a Uint16Array - sync', testInvalidInput, foobarUint16Array, execaSync);

Validate `input` option's type (#668)ehmickybefore adoption65742c6

lines 40–43why, one step back
40test('input option cannot be 0 - sync', testInvalidInput, 0, execaSync);
41test('input option cannot be false - sync', testInvalidInput, false, execaSync);42test('input option cannot be null - sync', testInvalidInput, null, execaSync);43test('input option cannot be a non-Readable stream - sync', testInvalidInput, new Writable(), execaSync);