Skip to content
Myr

split-newline.js

This file

Path

test/transform/split-newline.js

37 lines · 1.9 KiB · JavaScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

Rename files (#977)ehmickybefore adoption4b2e316

lines 1–2why, one step back
1import test from 'ava';
2import {execa, execaSync} from '../../index.js';

Upgrade xo (#980)ehmickybefore adoptionccfa412

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

Rename files (#977)ehmickybefore adoption4b2e316

lines 4–6why, one step back
4import {getOutputsGenerator, noopGenerator, noopAsyncGenerator} from '../helpers/generator.js';
5import {singleFull, singleFullEnd} from '../helpers/lines.js';6

Upgrade xo (#980)ehmickybefore adoptionccfa412

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

Rename files (#977)ehmickybefore adoption4b2e316

lines 8–37why, one step back
8
9const singleFullEndWindows = `${singleFull}\r\n`;10const mixedNewlines = '.\n.\r\n.\n.\r\n.\n';1112const testStripNewline = async (t, input, expectedOutput, execaMethod) => {13 const {stdout} = await execaMethod('noop.js', {14 stdout: getOutputsGenerator([input])(),15 stripFinalNewline: false,16 });17 t.is(stdout, expectedOutput);18};1920test('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd, execa);21test('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd, execa);22test('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows, execa);23test('Strips newline when user do not mistakenly yield one at the end, sync', testStripNewline, singleFull, singleFullEnd, execaSync);24test('Strips newline when user mistakenly yielded one at the end, sync', testStripNewline, singleFullEnd, singleFullEnd, execaSync);25test('Strips newline when user mistakenly yielded one at the end, Windows newline, sync', testStripNewline, singleFullEndWindows, singleFullEndWindows, execaSync);2627const testMixNewlines = async (t, generator, execaMethod) => {28 const {stdout} = await execaMethod('noop-fd.js', ['1', mixedNewlines], {29 stdout: generator(),30 stripFinalNewline: false,31 });32 t.is(stdout, mixedNewlines);33};3435test('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator, execa);36test('Can mix Unix and Windows newlines, sync', testMixNewlines, noopGenerator, execaSync);37test('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator, execa);