lines-mixed.js
This file
Path
test/stdio/lines-mixed.js
61 lines · 2.6 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
line 1why, one step back1import assert from 'node:assert/strict';100% test coverage (#1018)ehmickybefore adoption9f65b86
line 2why, one step back2import {Writable} from 'node:stream';TweaksSindre Sorhusbefore adoption698a1b8
line 3why, one step back3import test from 'node:test';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 4–14why, one step back4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {assertStreamOutput, assertStreamDataEvents, assertIterableChunks} from '../helpers/convert.js';6import {7 simpleFull,8 simpleLines,9 noNewlinesChunks,10 getSimpleChunkSubprocessAsync,11} from '../helpers/lines.js';1213setFixtureDirectory();14TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15const testAsyncIteration = async (expectedLines, stripFinalNewline) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 16why, one step back16 const subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});TweaksSindre Sorhusbefore adoption698a1b8
lines 17–18why, one step back17 assert.equal(subprocess.stdout.readableObjectMode, false);18 await assertStreamOutput(subprocess.stdout, simpleFull);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 19why, one step back19 const {stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20 assert.deepEqual(stdout, expectedLines);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 21–22why, one step back21};22TweaksSindre Sorhusbefore adoption698a1b8
lines 23–24why, one step back23test('"lines: true" works with stream async iteration', () => testAsyncIteration(simpleLines, false));24test('"lines: true" works with stream async iteration, stripFinalNewline', () => testAsyncIteration(noNewlinesChunks, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 25why, one step back25TweaksSindre Sorhusbefore adoption698a1b8
line 26why, one step back26const testDataEvents = async (expectedLines, stripFinalNewline) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 27why, one step back27 const subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});TweaksSindre Sorhusbefore adoption698a1b8
line 28why, one step back28 await assertStreamDataEvents(subprocess.stdout, simpleFull);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 29why, one step back29 const {stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30 assert.deepEqual(stdout, expectedLines);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 31–32why, one step back31};32TweaksSindre Sorhusbefore adoption698a1b8
lines 33–34why, one step back33test('"lines: true" works with stream "data" events', () => testDataEvents(simpleLines, false));34test('"lines: true" works with stream "data" events, stripFinalNewline', () => testDataEvents(noNewlinesChunks, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 35why, one step back35TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36const testWritableStream = async (expectedLines, stripFinalNewline) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 37–45why, one step back37 let output = '';38 const writable = new Writable({39 write(line, encoding, done) {40 output += line.toString();41 done();42 },43 decodeStrings: false,44 });45 const {stdout} = await getSimpleChunkSubprocessAsync({stripFinalNewline, stdout: ['pipe', writable]});TweaksSindre Sorhusbefore adoption698a1b8
lines 46–47why, one step back46 assert.deepEqual(output, simpleFull);47 assert.deepEqual(stdout, expectedLines);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 48–49why, one step back48};49TweaksSindre Sorhusbefore adoption698a1b8
lines 50–51why, one step back50test('"lines: true" works with writable streams targets', () => testWritableStream(simpleLines, false));51test('"lines: true" works with writable streams targets, stripFinalNewline', () => testWritableStream(noNewlinesChunks, true));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 52why, one step back52TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53const testIterable = async (expectedLines, stripFinalNewline) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 54why, one step back54 const subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});TweaksSindre Sorhusbefore adoption698a1b8
line 55why, one step back55 await assertIterableChunks(subprocess, noNewlinesChunks);100% test coverage (#1018)ehmickybefore adoption9f65b86
line 56why, one step back56 const {stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 57why, one step back57 assert.deepEqual(stdout, expectedLines);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 58–59why, one step back58};59TweaksSindre Sorhusbefore adoption698a1b8
lines 60–61why, one step back60test('"lines: true" works with subprocess.iterable()', () => testIterable(simpleLines, false));61test('"lines: true" works with subprocess.iterable(), stripFinalNewline', () => testIterable(noNewlinesChunks, true));