Skip to content
Myr

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 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–9why, one step back
3import {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();9

TweaksSindre Sorhusbefore adoption698a1b8

line 10why, one step back
10const testGeneratorFinal = async (fixtureName, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 11why, one step back
11 const {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});

TweaksSindre Sorhusbefore adoption698a1b8

line 12why, one step back
12 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 13–14why, one step back
13};
14

TweaksSindre Sorhusbefore adoption698a1b8

lines 15–18why, one step back
15test('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 back
19

TweaksSindre Sorhusbefore adoption698a1b8

line 20why, one step back
20const testFinalAlone = async (final, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 21why, one step back
21 const {stdout} = await execaMethod('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform}});

TweaksSindre Sorhusbefore adoption698a1b8

line 22why, one step back
22 assert.equal(stdout, `.\n${foobarString}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 25–27why, one step back
25test('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 back
28

TweaksSindre Sorhusbefore adoption698a1b8

line 29why, one step back
29const testFinalNoOutput = async (final, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 30why, one step back
30 const {stdout} = await execaMethod('empty.js', {stdout: {final: final(foobarString)().transform}});

TweaksSindre Sorhusbefore adoption698a1b8

line 31why, one step back
31 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 32–33why, one step back
32};
33

TweaksSindre Sorhusbefore adoption698a1b8

lines 34–36why, one step back
34test('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));