stdio.js
This file
Path
test/stdio.js
50 lines · 2.2 KiB · JavaScript
Last changed by
Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
History of this fileTake it
Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 1–23why, one step back1import util from 'util';2import test from 'ava';3import stdio from '../lib/stdio';45util.inspect.styles.name = 'magenta';67function macro(t, input, expected) {8 if (expected instanceof Error) {9 t.throws(() => stdio(input), expected.message);10 return;11 }1213 const result = stdio(input);1415 if (typeof expected === 'object' && expected !== null) {16 t.deepEqual(result, expected);17 } else {18 t.is(result, expected);19 }20}2122macro.title = (providedTitle, input) => providedTitle || util.inspect(input, {colors: true});23Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
lines 24–25why, one step back24test(macro, undefined, undefined);25test(macro, null, undefined);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 26–31why, one step back2627test(macro, {stdio: 'inherit'}, 'inherit');28test(macro, {stdio: 'pipe'}, 'pipe');29test(macro, {stdio: 'ignore'}, 'ignore');30test(macro, {stdio: [0, 1, 2]}, [0, 1, 2]);31Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
lines 32–36why, one step back32test(macro, {}, [undefined, undefined, undefined]);33test(macro, {stdio: []}, [undefined, undefined, undefined]);34test(macro, {stdin: 'pipe'}, ['pipe', undefined, undefined]);35test(macro, {stdout: 'ignore'}, [undefined, 'ignore', undefined]);36test(macro, {stderr: 'inherit'}, [undefined, undefined, 'inherit']);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 37why, one step back37test(macro, {stdin: 'pipe', stdout: 'ignore', stderr: 'inherit'}, ['pipe', 'ignore', 'inherit']);Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
lines 38–40why, one step back38test(macro, {stdin: 'pipe', stdout: 'ignore'}, ['pipe', 'ignore', undefined]);39test(macro, {stdin: 'pipe', stderr: 'inherit'}, ['pipe', undefined, 'inherit']);40test(macro, {stdout: 'ignore', stderr: 'inherit'}, [undefined, 'ignore', 'inherit']);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
line 41why, one step back41test(macro, {stdin: 0, stdout: 1, stderr: 2}, [0, 1, 2]);Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504
lines 42–44why, one step back42test(macro, {stdin: 0, stdout: 1}, [0, 1, undefined]);43test(macro, {stdin: 0, stderr: 2}, [0, undefined, 2]);44test(macro, {stdout: 1, stderr: 2}, [undefined, 1, 2]);Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a
lines 45–50why, one step back4546test(macro, {stdio: {foo: 'bar'}}, new TypeError('Expected `stdio` to be of type `string` or `Array`, got `object`'));4748test(macro, {stdin: 'inherit', stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));49test(macro, {stdin: 'inherit', stdio: ['pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));50test(macro, {stdin: 'inherit', stdio: [undefined, 'pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));