normalize-transform.js
This file
Path
test/transform/normalize-transform.js
56 lines · 3.9 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–10why, one step back3import {execa, execaSync} from '../../index.js';4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {foobarString, foobarUppercase, foobarUint8Array} from '../helpers/input.js';6import {casedSuffix} from '../helpers/generator.js';7import {generatorsMap} from '../helpers/map.js';89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11const testAppendInput = async (reversed, type, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 12–15why, one step back12 const stdin = [foobarUint8Array, generatorsMap[type].uppercase(), generatorsMap[type].append()];13 const reversedStdin = reversed ? stdin.reverse() : stdin;14 const {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: reversedStdin});15 const reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;TweaksSindre Sorhusbefore adoption698a1b8
line 16why, one step back16 assert.equal(stdout, `${foobarUppercase}${reversedSuffix}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 17–18why, one step back17};18TweaksSindre Sorhusbefore adoption698a1b8
lines 19–26why, one step back19test('Can use multiple generators as input', () => testAppendInput(false, 'generator', execa));20test('Can use multiple generators as input, reversed', () => testAppendInput(true, 'generator', execa));21test('Can use multiple generators as input, sync', () => testAppendInput(false, 'generator', execaSync));22test('Can use multiple generators as input, reversed, sync', () => testAppendInput(true, 'generator', execaSync));23test('Can use multiple duplexes as input', () => testAppendInput(false, 'duplex', execa));24test('Can use multiple duplexes as input, reversed', () => testAppendInput(true, 'duplex', execa));25test('Can use multiple webTransforms as input', () => testAppendInput(false, 'webTransform', execa));26test('Can use multiple webTransforms as input, reversed', () => testAppendInput(true, 'webTransform', execa));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 27why, one step back27TweaksSindre Sorhusbefore adoption698a1b8
line 28why, one step back28const testAppendOutput = async (reversed, type, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 29–32why, one step back29 const stdoutOption = [generatorsMap[type].uppercase(), generatorsMap[type].append()];30 const reversedStdoutOption = reversed ? stdoutOption.reverse() : stdoutOption;31 const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: reversedStdoutOption});32 const reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;TweaksSindre Sorhusbefore adoption698a1b8
line 33why, one step back33 assert.equal(stdout, `${foobarUppercase}${reversedSuffix}`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 34–35why, one step back34};35TweaksSindre Sorhusbefore adoption698a1b8
lines 36–43why, one step back36test('Can use multiple generators as output', () => testAppendOutput(false, 'generator', execa));37test('Can use multiple generators as output, reversed', () => testAppendOutput(true, 'generator', execa));38test('Can use multiple generators as output, sync', () => testAppendOutput(false, 'generator', execaSync));39test('Can use multiple generators as output, reversed, sync', () => testAppendOutput(true, 'generator', execaSync));40test('Can use multiple duplexes as output', () => testAppendOutput(false, 'duplex', execa));41test('Can use multiple duplexes as output, reversed', () => testAppendOutput(true, 'duplex', execa));42test('Can use multiple webTransforms as output', () => testAppendOutput(false, 'webTransform', execa));43test('Can use multiple webTransforms as output, reversed', () => testAppendOutput(true, 'webTransform', execa));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 44why, one step back44TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45const testGeneratorSyntax = async (type, usePlainObject, execaMethod) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 46–47why, one step back46 const transform = generatorsMap[type].uppercase();47 const {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: usePlainObject ? transform : transform.transform});TweaksSindre Sorhusbefore adoption698a1b8
line 48why, one step back48 assert.equal(stdout, foobarUppercase);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 49–50why, one step back49};50TweaksSindre Sorhusbefore adoption698a1b8
lines 51–56why, one step back51test('Can pass generators with an options plain object', () => testGeneratorSyntax('generator', false, execa));52test('Can pass generators without an options plain object', () => testGeneratorSyntax('generator', true, execa));53test('Can pass generators with an options plain object, sync', () => testGeneratorSyntax('generator', false, execaSync));54test('Can pass generators without an options plain object, sync', () => testGeneratorSyntax('generator', true, execaSync));55test('Can pass webTransforms with an options plain object', () => testGeneratorSyntax('webTransform', true, execa));56test('Can pass webTransforms without an options plain object', () => testGeneratorSyntax('webTransform', false, execa));