Skip to content
Myr

generator-final.js

This file

Path

test/transform/generator-final.js

35 lines · 2.0 KiB · JavaScript

Last changed by

100% test coverage (#1018)ehmickybefore adoption9f65b86

History of this file

Take it

Rename files (#977)ehmickybefore adoption4b2e316

lines 1–4why, one step back
1import test from 'ava';
2import {execa, execaSync} from '../../index.js';3import {foobarString} from '../helpers/input.js';4import {getOutputAsyncGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 5why, one step back
5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';

Rename files (#977)ehmickybefore adoption4b2e316

line 6why, one step back
6

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 7why, one step back
7setFixtureDirectory();

Rename files (#977)ehmickybefore adoption4b2e316

lines 8–19why, one step back
8
9const testGeneratorFinal = async (t, fixtureName, execaMethod) => {10 const {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});11 t.is(stdout, foobarString);12};1314test('Generators "final" can be used', testGeneratorFinal, 'noop.js', execa);15test('Generators "final" is used even on empty streams', testGeneratorFinal, 'empty.js', execa);16test('Generators "final" can be used, sync', testGeneratorFinal, 'noop.js', execaSync);17test('Generators "final" is used even on empty streams, sync', testGeneratorFinal, 'empty.js', execaSync);1819const testFinalAlone = async (t, final, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 20–21why, one step back
20 const {stdout} = await execaMethod('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform}});
21 t.is(stdout, `.\n${foobarString}`);

Rename files (#977)ehmickybefore adoption4b2e316

lines 22–35why, one step back
22};
2324test('Generators "final" can be used without "transform"', testFinalAlone, getOutputGenerator, execa);25test('Generators "final" can be used without "transform", sync', testFinalAlone, getOutputGenerator, execaSync);26test('Generators "final" can be used without "transform", async', testFinalAlone, getOutputAsyncGenerator, execa);2728const testFinalNoOutput = async (t, final, execaMethod) => {29 const {stdout} = await execaMethod('empty.js', {stdout: {final: final(foobarString)().transform}});30 t.is(stdout, foobarString);31};3233test('Generators "final" can be used without "transform" nor output', testFinalNoOutput, getOutputGenerator, execa);34test('Generators "final" can be used without "transform" nor output, sync', testFinalNoOutput, getOutputGenerator, execaSync);35test('Generators "final" can be used without "transform" nor output, async', testFinalNoOutput, getOutputAsyncGenerator, execa);