command.js
This file
Path
test/command.js
60 lines · 2.0 KiB · JavaScript
Last changed by
Improve input validation (#838)ehmickybefore adoption8ee137c
History of this fileTake it
The walk stopped after 200 commits: lines older than 5320fef point at it.
Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
line 1why, one step back1import test from 'ava';Split files (#791)ehmickybefore adoption932fb26
line 2why, one step back2import {execaCommand, execaCommandSync} from '../index.js';Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 3–7why, one step back3import {setFixtureDir} from './helpers/fixtures-dir.js';45setFixtureDir();67test('execaCommand()', async t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 8why, one step back8 const {stdout} = await execaCommand('echo.js foo bar');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 9–12why, one step back9 t.is(stdout, 'foo\nbar');10});1112test('execaCommand() ignores consecutive spaces', async t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 13why, one step back13 const {stdout} = await execaCommand('echo.js foo bar');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 14–22why, one step back14 t.is(stdout, 'foo\nbar');15});1617test('execaCommand() allows escaping spaces in commands', async t => {18 const {stdout} = await execaCommand('command\\ with\\ space.js foo bar');19 t.is(stdout, 'foo\nbar');20});2122test('execaCommand() allows escaping spaces in arguments', async t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 23why, one step back23 const {stdout} = await execaCommand('echo.js foo\\ bar');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 24–27why, one step back24 t.is(stdout, 'foo bar');25});2627test('execaCommand() escapes other whitespaces', async t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 28why, one step back28 const {stdout} = await execaCommand('echo.js foo\tbar');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 29–32why, one step back29 t.is(stdout, 'foo\tbar');30});3132test('execaCommand() trims', async t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 33why, one step back33 const {stdout} = await execaCommand(' echo.js foo bar ');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
lines 34–37why, one step back34 t.is(stdout, 'foo\nbar');35});3637test('execaCommandSync()', t => {Simplify tests (#552)ehmickybefore adoption5fa61d8
line 38why, one step back38 const {stdout} = execaCommandSync('echo.js foo bar');Improve documentation of the usage section (#541)ehmickybefore adoption5320fef
line 39why, one step back39 t.is(stdout, 'foo\nbar');Fix default value of `stdin` with `$` (#550)ehmickybefore adoption6fe7e51
line 40why, one step back40});Improve input validation (#838)ehmickybefore adoption8ee137c
lines 41–60why, one step back4142const testInvalidCommand = (t, execaCommand, invalidArgument) => {43 t.throws(() => {44 execaCommand(invalidArgument);45 }, {message: /First argument must be a string/});46};4748test('execaCommand() must use a string', testInvalidCommand, execaCommand, true);49test('execaCommandSync() must use a string', testInvalidCommand, execaCommandSync, true);50test('execaCommand() must have an argument', testInvalidCommand, execaCommand, undefined);51test('execaCommandSync() must have an argument', testInvalidCommand, execaCommandSync, undefined);5253const testInvalidArgs = (t, execaCommand) => {54 t.throws(() => {55 execaCommand('echo', ['']);56 }, {message: /Last argument must be an options object/});57};5859test('execaCommand() must not pass an array of arguments', testInvalidArgs, execaCommand);60test('execaCommandSync() must not pass an array of arguments', testInvalidArgs, execaCommandSync);