Skip to content
Myr

script.js

This file

Path

test/script.js

59 lines · 2.0 KiB · JavaScript

Last changed by

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

History of this file

Take it

Split files (#791)ehmickybefore adoption932fb26

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

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

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

Split files (#791)ehmickybefore adoption932fb26

lines 6–8why, one step back
6
7setFixtureDir();8

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

lines 9–10why, one step back
9const testScriptStdoutSync = (t, getSubprocess, expectedStdout) => {
10 const {stdout} = getSubprocess();

Allow newlines in `$` (#843)ehmickybefore adoption1315486

lines 11–12why, one step back
11 t.is(stdout, expectedStdout);
12};

Split files (#791)ehmickybefore adoption932fb26

line 13why, one step back
13

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 14–17why, one step back
14test('$.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`);

Split files (#791)ehmickybefore adoption932fb26

line 18why, one step back
18

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 19–21why, one step back
19test('Cannot call $.sync.sync', t => {
20 t.false('sync' in $.sync);21});

Split files (#791)ehmickybefore adoption932fb26

line 22why, one step back
22

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 23–25why, one step back
23test('Cannot call $.sync(options).sync', t => {
24 t.false('sync' in $.sync({}));25});

Split files (#791)ehmickybefore adoption932fb26

line 26why, one step back
26

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 27–30why, one step back
27test('$(options)() stdin defaults to "inherit"', async t => {
28 const {stdout} = await $({input: foobarString})('stdin-script.js');29 t.is(stdout, foobarString);30});

Split files (#791)ehmickybefore adoption932fb26

line 31why, one step back
31

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 32–34why, one step back
32test('$.sync(options)() stdin defaults to "inherit"', t => {
33 const {stdout} = $.sync({input: foobarString})('stdin-script.js');34 t.is(stdout, foobarString);

Split files (#791)ehmickybefore adoption932fb26

lines 35–36why, one step back
35});
36

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 37–39why, one step back
37test('$(options).sync() stdin defaults to "inherit"', t => {
38 const {stdout} = $({input: foobarString}).sync('stdin-script.js');39 t.is(stdout, foobarString);

Improve input validation (#838)ehmickybefore adoption8ee137c

lines 40–41why, one step back
40});
41

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 42–44why, one step back
42test('$(options)`...` stdin defaults to "inherit"', async t => {
43 const {stdout} = await $({input: foobarString})`stdin-script.js`;44 t.is(stdout, foobarString);

Split files (#791)ehmickybefore adoption932fb26

lines 45–46why, one step back
45});
46

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 47–49why, one step back
47test('$.sync(options)`...` stdin defaults to "inherit"', t => {
48 const {stdout} = $.sync({input: foobarString})`stdin-script.js`;49 t.is(stdout, foobarString);

Split files (#791)ehmickybefore adoption932fb26

lines 50–51why, one step back
50});
51

Allow template strings with all methods (#933)ehmickybefore adoption8074d85

lines 52–54why, one step back
52test('$(options).sync`...` stdin defaults to "inherit"', t => {
53 const {stdout} = $({input: foobarString}).sync`stdin-script.js`;54 t.is(stdout, foobarString);

Split files (#791)ehmickybefore adoption932fb26

lines 55–59why, one step back
55});
5657test('$ stdin has no default value when stdio is set', t => {58 t.true(isStream($({stdio: 'pipe'})`noop.js`.stdin));59});