generator-final.js
This file
Path
test/transform/generator-final.js
36 lines · 2.1 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–9why, one step back3import {execa, execaSync} from '../../index.js';4import {foobarString} from '../helpers/input.js';5import {getOutputAsyncGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';6import {setFixtureDirectory} from '../helpers/fixtures-directory.js';78setFixtureDirectory();9TweaksSindre Sorhusbefore adoption698a1b8
line 10why, one step back10const testGeneratorFinal = async (fixtureName, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 11why, one step back11 const {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 13–14why, one step back13};14TweaksSindre Sorhusbefore adoption698a1b8
lines 15–18why, one step back15test('Generators "final" can be used', () => testGeneratorFinal('noop.js', execa));16test('Generators "final" is used even on empty streams', () => testGeneratorFinal('empty.js', execa));17test('Generators "final" can be used, sync', () => testGeneratorFinal('noop.js', execaSync));18test('Generators "final" is used even on empty streams, sync', () => testGeneratorFinal('empty.js', execaSync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 19why, one step back19TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20const testFinalAlone = async (final, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 21why, one step back21 const {stdout} = await execaMethod('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform}});TweaksSindre Sorhusbefore adoption698a1b8
line 22why, one step back22 assert.equal(stdout, `.\n${foobarString}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 23–24why, one step back23};24TweaksSindre Sorhusbefore adoption698a1b8
lines 25–27why, one step back25test('Generators "final" can be used without "transform"', () => testFinalAlone(getOutputGenerator, execa));26test('Generators "final" can be used without "transform", sync', () => testFinalAlone(getOutputGenerator, execaSync));27test('Generators "final" can be used without "transform", async', () => testFinalAlone(getOutputAsyncGenerator, execa));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 28why, one step back28TweaksSindre Sorhusbefore adoption698a1b8
line 29why, one step back29const testFinalNoOutput = async (final, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 30why, one step back30 const {stdout} = await execaMethod('empty.js', {stdout: {final: final(foobarString)().transform}});TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 32–33why, one step back32};33TweaksSindre Sorhusbefore adoption698a1b8
lines 34–36why, one step back34test('Generators "final" can be used without "transform" nor output', () => testFinalNoOutput(getOutputGenerator, execa));35test('Generators "final" can be used without "transform" nor output, sync', () => testFinalNoOutput(getOutputGenerator, execaSync));36test('Generators "final" can be used without "transform" nor output, async', () => testFinalNoOutput(getOutputAsyncGenerator, execa));