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 fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–18why, one step back3import {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();18TweaksSindre Sorhusbefore adoption698a1b8
line 19why, one step back19const testStreamLinesNoop = async (lines, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 20why, one step back20 const {stdout} = await execaMethod('noop-fd.js', ['1', simpleFull], {lines});TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21 assert.equal(stdout, simpleFull);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 22–23why, one step back22};23TweaksSindre Sorhusbefore adoption698a1b8
lines 24–29why, one step back24test('"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 back30TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31const testLinesObjectMode = async (lines, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 32–35why, one step back32 const {stdout} = await execaMethod('noop.js', {33 stdout: getOutputsGenerator([foobarObject])(true),34 lines,35 });TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36 assert.deepEqual(stdout, [foobarObject]);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 37–38why, one step back37};38TweaksSindre Sorhusbefore adoption698a1b8
lines 39–42why, one step back39test('"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 back4344// eslint-disable-next-line max-paramsTweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45const testEncoding = async (input, expectedOutput, encoding, lines, stripFinalNewline, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 46–51why, one step back46 const {stdout} = await execaMethod('stdin.js', {47 lines,48 stripFinalNewline,49 encoding,50 input,51 });TweaksSindre Sorhusbefore adoption698a1b8
line 52why, one step back52 assert.deepEqual(stdout, expectedOutput);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 53–54why, one step back53};54TweaksSindre Sorhusbefore adoption698a1b8
lines 55–78why, one step back55test('"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 back79TweaksSindre Sorhusbefore adoption698a1b8
line 80why, one step back80const testLinesNoBuffer = async (lines, buffer, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 81why, one step back81 const {stdout} = await getSimpleChunkSubprocess(execaMethod, {lines, buffer});TweaksSindre Sorhusbefore adoption698a1b8
line 82why, one step back82 assert.equal(stdout, undefined);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 83–84why, one step back83};84TweaksSindre Sorhusbefore adoption698a1b8
lines 85–90why, one step back85test('"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));