MCPcopy Create free account
hub / github.com/sindresorhus/execa / testGeneratorInputPipe

Function testGeneratorInputPipe

test/transform/generator-input.js:68–76  ·  view source on GitHub ↗
(t, useShortcutProperty, objectMode, addNoopTransform, type, input)

Source from the content-addressed store, hash-verified

66
67// eslint-disable-next-line max-params
68const testGeneratorInputPipe = async (t, useShortcutProperty, objectMode, addNoopTransform, type, input) => {
69 const {generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);
70 const subprocess = execa('stdin-fd.js', ['0'], getStdio(0, generators));
71 const stream = useShortcutProperty ? subprocess.stdin : subprocess.stdio[0];
72 stream.end(...input);
73 const {stdout} = await subprocess;
74 const expectedOutput = input[1] === 'utf16le' ? Buffer.from(output, input[1]).toString() : output;
75 t.is(stdout, expectedOutput);
76};
77
78test('Can use generators with subprocess.stdio[0] and default encoding', testGeneratorInputPipe, false, false, false, 'generator', [foobarString, 'utf8']);
79test('Can use generators with subprocess.stdin and default encoding', testGeneratorInputPipe, true, false, false, 'generator', [foobarString, 'utf8']);

Callers

nothing calls this directly

Calls 2

getStdioFunction · 0.90
getInputObjectModeFunction · 0.85

Tested by

no test coverage detected