Skip to content
Myr

script.js

This file

Path

test/methods/script.js

60 lines · 2.2 KiB · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–2why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 3–9why, one step back
3import {isStream} from 'is-stream';
4import {$} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString} from '../helpers/input.js';78setFixtureDirectory();9

TweaksSindre Sorhusbefore adoption698a1b8

line 10why, one step back
10const testScriptStdoutSync = (getSubprocess, expectedStdout) => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 11why, one step back
11 const {stdout} = getSubprocess();

TweaksSindre Sorhusbefore adoption698a1b8

line 12why, one step back
12 assert.equal(stdout, expectedStdout);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 13–14why, one step back
13};
14

TweaksSindre Sorhusbefore adoption698a1b8

lines 15–18why, one step back
15test('$.sync`...`', () => testScriptStdoutSync(() => $.sync`echo.js foo bar`, 'foo\nbar'));
16test('$.s`...`', () => testScriptStdoutSync(() => $.s`echo.js foo bar`, 'foo\nbar'));17test('$(options).sync`...`', () => testScriptStdoutSync(() => $({stripFinalNewline: false}).sync`echo.js ${foobarString}`, `${foobarString}\n`));18test('$.sync(options)`...`', () => testScriptStdoutSync(() => $.sync({stripFinalNewline: false})`echo.js ${foobarString}`, `${foobarString}\n`));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 19why, one step back
19

TweaksSindre Sorhusbefore adoption698a1b8

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 22–23why, one step back
22});
23

TweaksSindre Sorhusbefore adoption698a1b8

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 26–27why, one step back
26});
27

TweaksSindre Sorhusbefore adoption698a1b8

line 28why, one step back
28test('$(options)() stdin defaults to "inherit"', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 29why, one step back
29 const {stdout} = await $({input: foobarString})('stdin-script.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 30why, one step back
30 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 31–32why, one step back
31});
32

TweaksSindre Sorhusbefore adoption698a1b8

line 33why, one step back
33test('$.sync(options)() stdin defaults to "inherit"', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 34why, one step back
34 const {stdout} = $.sync({input: foobarString})('stdin-script.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 35why, one step back
35 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 38why, one step back
38test('$(options).sync() stdin defaults to "inherit"', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 39why, one step back
39 const {stdout} = $({input: foobarString}).sync('stdin-script.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 40why, one step back
40 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 43why, one step back
43test('$(options)`...` stdin defaults to "inherit"', async () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 44why, one step back
44 const {stdout} = await $({input: foobarString})`stdin-script.js`;

TweaksSindre Sorhusbefore adoption698a1b8

line 45why, one step back
45 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 48why, one step back
48test('$.sync(options)`...` stdin defaults to "inherit"', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 49why, one step back
49 const {stdout} = $.sync({input: foobarString})`stdin-script.js`;

TweaksSindre Sorhusbefore adoption698a1b8

line 50why, one step back
50 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

line 53why, one step back
53test('$(options).sync`...` stdin defaults to "inherit"', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 54why, one step back
54 const {stdout} = $({input: foobarString}).sync`stdin-script.js`;

TweaksSindre Sorhusbefore adoption698a1b8

line 55why, one step back
55 assert.equal(stdout, foobarString);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 56–57why, one step back
56});
57

TweaksSindre Sorhusbefore adoption698a1b8

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 60why, one step back
60});