Skip to content
Myr

script.js

This file

Path

test/methods/script.js

59 lines · 2.0 KiB · JavaScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

Rename files (#977)ehmickybefore adoption4b2e316

lines 1–3why, one step back
1import test from 'ava';
2import {isStream} from 'is-stream';3import {$} from '../../index.js';

Upgrade xo (#980)ehmickybefore adoptionccfa412

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

Rename files (#977)ehmickybefore adoption4b2e316

lines 5–6why, one step back
5import {foobarString} from '../helpers/input.js';
6

Upgrade xo (#980)ehmickybefore adoptionccfa412

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

Rename files (#977)ehmickybefore adoption4b2e316

lines 8–59why, one step back
8
9const testScriptStdoutSync = (t, getSubprocess, expectedStdout) => {10 const {stdout} = getSubprocess();11 t.is(stdout, expectedStdout);12};1314test('$.sync`...`', testScriptStdoutSync, () => $.sync`echo.js foo bar`, 'foo\nbar');15test('$.s`...`', testScriptStdoutSync, () => $.s`echo.js foo bar`, 'foo\nbar');16test('$(options).sync`...`', testScriptStdoutSync, () => $({stripFinalNewline: false}).sync`echo.js ${foobarString}`, `${foobarString}\n`);17test('$.sync(options)`...`', testScriptStdoutSync, () => $.sync({stripFinalNewline: false})`echo.js ${foobarString}`, `${foobarString}\n`);1819test('Cannot call $.sync.sync', t => {20 t.false('sync' in $.sync);21});2223test('Cannot call $.sync(options).sync', t => {24 t.false('sync' in $.sync({}));25});2627test('$(options)() stdin defaults to "inherit"', async t => {28 const {stdout} = await $({input: foobarString})('stdin-script.js');29 t.is(stdout, foobarString);30});3132test('$.sync(options)() stdin defaults to "inherit"', t => {33 const {stdout} = $.sync({input: foobarString})('stdin-script.js');34 t.is(stdout, foobarString);35});3637test('$(options).sync() stdin defaults to "inherit"', t => {38 const {stdout} = $({input: foobarString}).sync('stdin-script.js');39 t.is(stdout, foobarString);40});4142test('$(options)`...` stdin defaults to "inherit"', async t => {43 const {stdout} = await $({input: foobarString})`stdin-script.js`;44 t.is(stdout, foobarString);45});4647test('$.sync(options)`...` stdin defaults to "inherit"', t => {48 const {stdout} = $.sync({input: foobarString})`stdin-script.js`;49 t.is(stdout, foobarString);50});5152test('$(options).sync`...` stdin defaults to "inherit"', t => {53 const {stdout} = $({input: foobarString}).sync`stdin-script.js`;54 t.is(stdout, foobarString);55});5657test('$ stdin has no default value when stdio is set', t => {58 t.true(isStream($({stdio: 'pipe'})`noop.js`.stdin));59});