@@ -6,7 +6,7 @@ import test from 'ava';
66import getStream from 'get-stream' ;
77import { pEvent } from 'p-event' ;
88import tempfile from 'tempfile' ;
9- import { execa , execaSync } from '../index.js' ;
9+ import { execa , execaSync , $ } from '../index.js' ;
1010import { setFixtureDir } from './helpers/fixtures-dir.js' ;
1111
1212setFixtureDir ( ) ;
@@ -71,13 +71,25 @@ test('input can be a Stream', async t => {
7171 t . is ( stdout , 'howdy' ) ;
7272} ) ;
7373
74+ test ( 'input option can be used with $' , async t => {
75+ const { stdout} = await $ ( { input : 'foobar' } ) `stdin.js` ;
76+ t . is ( stdout , 'foobar' ) ;
77+ } ) ;
78+
7479test ( 'inputFile can be set' , async t => {
7580 const inputFile = tempfile ( ) ;
7681 fs . writeFileSync ( inputFile , 'howdy' ) ;
7782 const { stdout} = await execa ( 'stdin.js' , { inputFile} ) ;
7883 t . is ( stdout , 'howdy' ) ;
7984} ) ;
8085
86+ test ( 'inputFile can be set with $' , async t => {
87+ const inputFile = tempfile ( ) ;
88+ fs . writeFileSync ( inputFile , 'howdy' ) ;
89+ const { stdout} = await $ ( { inputFile} ) `stdin.js` ;
90+ t . is ( stdout , 'howdy' ) ;
91+ } ) ;
92+
8193test ( 'inputFile and input cannot be both set' , t => {
8294 t . throws ( ( ) => execa ( 'stdin.js' , { inputFile : '' , input : '' } ) , {
8395 message : / c a n n o t b e b o t h s e t / ,
@@ -96,6 +108,11 @@ test('input option can be a String - sync', t => {
96108 t . is ( stdout , 'foobar' ) ;
97109} ) ;
98110
111+ test ( 'input option can be used with $.sync' , t => {
112+ const { stdout} = $ ( { input : 'foobar' } ) . sync `stdin.js` ;
113+ t . is ( stdout , 'foobar' ) ;
114+ } ) ;
115+
99116test ( 'input option can be a Buffer - sync' , t => {
100117 const { stdout} = execaSync ( 'stdin.js' , { input : Buffer . from ( 'testing12' , 'utf8' ) } ) ;
101118 t . is ( stdout , 'testing12' ) ;
@@ -125,6 +142,13 @@ test('inputFile can be set - sync', t => {
125142 t . is ( stdout , 'howdy' ) ;
126143} ) ;
127144
145+ test ( 'inputFile option can be used with $.sync' , t => {
146+ const inputFile = tempfile ( ) ;
147+ fs . writeFileSync ( inputFile , 'howdy' ) ;
148+ const { stdout} = $ ( { inputFile} ) . sync `stdin.js` ;
149+ t . is ( stdout , 'howdy' ) ;
150+ } ) ;
151+
128152test ( 'inputFile and input cannot be both set - sync' , t => {
129153 t . throws ( ( ) => execaSync ( 'stdin.js' , { inputFile : '' , input : '' } ) , {
130154 message : / c a n n o t b e b o t h s e t / ,
0 commit comments