Skip to content
Myr

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

TweaksSindre Sorhusbefore adoption698a1b8

line 11why, one step back
11const testAppendInput = async (reversed, type, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 12–15why, one step back
12 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 back
16 assert.equal(stdout, `${foobarUppercase}${reversedSuffix}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 17–18why, one step back
17};
18

TweaksSindre Sorhusbefore adoption698a1b8

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

TweaksSindre Sorhusbefore adoption698a1b8

line 28why, one step back
28const testAppendOutput = async (reversed, type, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 29–32why, one step back
29 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 back
33 assert.equal(stdout, `${foobarUppercase}${reversedSuffix}`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 34–35why, one step back
34};
35

TweaksSindre Sorhusbefore adoption698a1b8

lines 36–43why, one step back
36test('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 back
44

TweaksSindre Sorhusbefore adoption698a1b8

line 45why, one step back
45const testGeneratorSyntax = async (type, usePlainObject, execaMethod) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 46–47why, one step back
46 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 back
48 assert.equal(stdout, foobarUppercase);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 49–50why, one step back
49};
50

TweaksSindre Sorhusbefore adoption698a1b8

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