Skip to content
Myr

lines-noop.js

This file

Path

test/stdio/lines-noop.js

90 lines · 7.0 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 3–18why, one step back
3import {execa, execaSync} from '../../index.js';
4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {getOutputsGenerator} from '../helpers/generator.js';6import {foobarObject} from '../helpers/input.js';7import {8 simpleFull,9 simpleFullUint8Array,10 simpleFullHex,11 simpleFullUtf16Uint8Array,12 simpleLines,13 noNewlinesChunks,14 getSimpleChunkSubprocess,15} from '../helpers/lines.js';1617setFixtureDirectory();18

TweaksSindre Sorhusbefore adoption698a1b8

line 19why, one step back
19const testStreamLinesNoop = async (lines, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 20why, one step back
20 const {stdout} = await execaMethod('noop-fd.js', ['1', simpleFull], {lines});

TweaksSindre Sorhusbefore adoption698a1b8

line 21why, one step back
21 assert.equal(stdout, simpleFull);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 22–23why, one step back
22};
23

TweaksSindre Sorhusbefore adoption698a1b8

lines 24–29why, one step back
24test('"lines: false" is a noop', () => testStreamLinesNoop(false, execa));
25test('"lines: false" is a noop, fd-specific', () => testStreamLinesNoop({stderr: true}, execa));26test('"lines: false" is a noop, fd-specific none', () => testStreamLinesNoop({}, execa));27test('"lines: false" is a noop, sync', () => testStreamLinesNoop(false, execaSync));28test('"lines: false" is a noop, fd-specific, sync', () => testStreamLinesNoop({stderr: true}, execaSync));29test('"lines: false" is a noop, fd-specific none, sync', () => testStreamLinesNoop({}, execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 30why, one step back
30

TweaksSindre Sorhusbefore adoption698a1b8

line 31why, one step back
31const testLinesObjectMode = async (lines, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 32–35why, one step back
32 const {stdout} = await execaMethod('noop.js', {
33 stdout: getOutputsGenerator([foobarObject])(true),34 lines,35 });

TweaksSindre Sorhusbefore adoption698a1b8

line 36why, one step back
36 assert.deepEqual(stdout, [foobarObject]);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 37–38why, one step back
37};
38

TweaksSindre Sorhusbefore adoption698a1b8

lines 39–42why, one step back
39test('"lines: true" is a noop with objects generators, objectMode', () => testLinesObjectMode(true, execa));
40test('"lines: true" is a noop with objects generators, fd-specific, objectMode', () => testLinesObjectMode({stdout: true}, execa));41test('"lines: true" is a noop with objects generators, objectMode, sync', () => testLinesObjectMode(true, execaSync));42test('"lines: true" is a noop with objects generators, fd-specific, objectMode, sync', () => testLinesObjectMode({stdout: true}, execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 43–44why, one step back
43
44// eslint-disable-next-line max-params

TweaksSindre Sorhusbefore adoption698a1b8

line 45why, one step back
45const testEncoding = async (input, expectedOutput, encoding, lines, stripFinalNewline, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 46–51why, one step back
46 const {stdout} = await execaMethod('stdin.js', {
47 lines,48 stripFinalNewline,49 encoding,50 input,51 });

TweaksSindre Sorhusbefore adoption698a1b8

line 52why, one step back
52 assert.deepEqual(stdout, expectedOutput);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 53–54why, one step back
53};
54

TweaksSindre Sorhusbefore adoption698a1b8

lines 55–78why, one step back
55test('"lines: true" is a noop with "encoding: utf16"', () => testEncoding(simpleFullUtf16Uint8Array, simpleLines, 'utf16le', true, false, execa));
56test('"lines: true" is a noop with "encoding: utf16", fd-specific', () => testEncoding(simpleFullUtf16Uint8Array, simpleLines, 'utf16le', {stdout: true}, false, execa));57test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline', () => testEncoding(simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, true, execa));58test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline, fd-specific', () => testEncoding(simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, {stdout: true}, execa));59test('"lines: true" is a noop with "encoding: buffer"', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, false, execa));60test('"lines: true" is a noop with "encoding: buffer", fd-specific', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', {stdout: true}, false, execa));61test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, false, execa));62test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline, fd-specific', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, {stdout: false}, execa));63test('"lines: true" is a noop with "encoding: hex"', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, false, execa));64test('"lines: true" is a noop with "encoding: hex", fd-specific', () => testEncoding(simpleFull, simpleFullHex, 'hex', {stdout: true}, false, execa));65test('"lines: true" is a noop with "encoding: hex", stripFinalNewline', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, true, execa));66test('"lines: true" is a noop with "encoding: hex", stripFinalNewline, fd-specific', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, {stdout: true}, execa));67test('"lines: true" is a noop with "encoding: utf16", sync', () => testEncoding(simpleFullUtf16Uint8Array, simpleLines, 'utf16le', true, false, execaSync));68test('"lines: true" is a noop with "encoding: utf16", fd-specific, sync', () => testEncoding(simpleFullUtf16Uint8Array, simpleLines, 'utf16le', {stdout: true}, false, execaSync));69test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline, sync', () => testEncoding(simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, true, execaSync));70test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline, fd-specific, sync', () => testEncoding(simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, {stdout: true}, execaSync));71test('"lines: true" is a noop with "encoding: buffer", sync', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, false, execaSync));72test('"lines: true" is a noop with "encoding: buffer", fd-specific, sync', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', {stdout: true}, false, execaSync));73test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline, sync', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, false, execaSync));74test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline, fd-specific, sync', () => testEncoding(simpleFull, simpleFullUint8Array, 'buffer', true, {stdout: false}, execaSync));75test('"lines: true" is a noop with "encoding: hex", sync', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, false, execaSync));76test('"lines: true" is a noop with "encoding: hex", fd-specific, sync', () => testEncoding(simpleFull, simpleFullHex, 'hex', {stdout: true}, false, execaSync));77test('"lines: true" is a noop with "encoding: hex", stripFinalNewline, sync', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, true, execaSync));78test('"lines: true" is a noop with "encoding: hex", stripFinalNewline, fd-specific, sync', () => testEncoding(simpleFull, simpleFullHex, 'hex', true, {stdout: true}, execaSync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 79why, one step back
79

TweaksSindre Sorhusbefore adoption698a1b8

line 80why, one step back
80const testLinesNoBuffer = async (lines, buffer, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 81why, one step back
81 const {stdout} = await getSimpleChunkSubprocess(execaMethod, {lines, buffer});

TweaksSindre Sorhusbefore adoption698a1b8

line 82why, one step back
82 assert.equal(stdout, undefined);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 83–84why, one step back
83};
84

TweaksSindre Sorhusbefore adoption698a1b8

lines 85–90why, one step back
85test('"lines: true" is a noop with "buffer: false"', () => testLinesNoBuffer(true, false, execa));
86test('"lines: true" is a noop with "buffer: false", fd-specific buffer', () => testLinesNoBuffer(true, {stdout: false}, execa));87test('"lines: true" is a noop with "buffer: false", fd-specific lines', () => testLinesNoBuffer({stdout: true}, false, execa));88test('"lines: true" is a noop with "buffer: false", sync', () => testLinesNoBuffer(true, false, execaSync));89test('"lines: true" is a noop with "buffer: false", fd-specific buffer, sync', () => testLinesNoBuffer(true, {stdout: false}, execaSync));90test('"lines: true" is a noop with "buffer: false", fd-specific lines, sync', () => testLinesNoBuffer({stdout: true}, false, execaSync));