Skip to content
Myr

bind.js

This file

Path

test/methods/bind.js

111 lines · 5.6 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

line 1why, one step back
1import assert from 'node:assert/strict';

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

line 2why, one step back
2import path from 'node:path';

TweaksSindre Sorhusbefore adoption698a1b8

lines 3–4why, one step back
3import test from 'node:test';
4import {assertRejects} from '../helpers/assert.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 5–16why, one step back
5import {
6 execa,7 execaSync,8 execaNode,9 $,10} from '../../index.js';11import {foobarString, foobarUppercase} from '../helpers/input.js';12import {uppercaseGenerator} from '../helpers/generator.js';13import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';1415setFixtureDirectory();16

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

lines 17–18why, one step back
17const NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');
18const PRINT_ENV_PATH = path.join(FIXTURES_DIRECTORY, 'environment.js');

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 19why, one step back
19

TweaksSindre Sorhusbefore adoption698a1b8

line 20why, one step back
20const testBindOptions = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 21why, one step back
21 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);

TweaksSindre Sorhusbefore adoption698a1b8

line 22why, one step back
22 assert.equal(stdout, `${foobarString}\n`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 23–24why, one step back
23};
24

TweaksSindre Sorhusbefore adoption698a1b8

lines 25–27why, one step back
25test('execa() can bind options', () => testBindOptions(execa));
26test('execaNode() can bind options', () => testBindOptions(execaNode));27test('$ can bind options', () => testBindOptions($));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 28why, one step back
28

TweaksSindre Sorhusbefore adoption698a1b8

line 29why, one step back
29const testBindOptionsSync = execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 30why, one step back
30 const {stdout} = execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);

TweaksSindre Sorhusbefore adoption698a1b8

line 31why, one step back
31 assert.equal(stdout, `${foobarString}\n`);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 32–33why, one step back
32};
33

TweaksSindre Sorhusbefore adoption698a1b8

lines 34–35why, one step back
34test('execaSync() can bind options', () => testBindOptionsSync(execaSync));
35test('$.sync can bind options', () => testBindOptionsSync($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 36why, one step back
36

TweaksSindre Sorhusbefore adoption698a1b8

line 37why, one step back
37const testBindPriority = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 38why, one step back
38 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: true});

TweaksSindre Sorhusbefore adoption698a1b8

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 42–46why, one step back
42test('execa() bound options have lower priority', () => testBindPriority(execa));
43test('execaSync() bound options have lower priority', () => testBindPriority(execaSync));44test('execaNode() bound options have lower priority', () => testBindPriority(execaNode));45test('$ bound options have lower priority', () => testBindPriority($));46test('$.sync bound options have lower priority', () => testBindPriority($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 47why, one step back
47

TweaksSindre Sorhusbefore adoption698a1b8

line 48why, one step back
48const testBindUndefined = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 49why, one step back
49 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: undefined});

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

lines 53–57why, one step back
53test('execa() undefined options use default value', () => testBindUndefined(execa));
54test('execaSync() undefined options use default value', () => testBindUndefined(execaSync));55test('execaNode() undefined options use default value', () => testBindUndefined(execaNode));56test('$ undefined options use default value', () => testBindUndefined($));57test('$.sync undefined options use default value', () => testBindUndefined($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 58why, one step back
58

TweaksSindre Sorhusbefore adoption698a1b8

line 59why, one step back
59const testMergeEnv = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 60why, one step back
60 const {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: 'bar'}});

TweaksSindre Sorhusbefore adoption698a1b8

line 61why, one step back
61 assert.equal(stdout, 'foo\nbar');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 62–63why, one step back
62};
63

TweaksSindre Sorhusbefore adoption698a1b8

lines 64–68why, one step back
64test('execa() bound options are merged', () => testMergeEnv(execa));
65test('execaSync() bound options are merged', () => testMergeEnv(execaSync));66test('execaNode() bound options are merged', () => testMergeEnv(execaNode));67test('$ bound options are merged', () => testMergeEnv($));68test('$.sync bound options are merged', () => testMergeEnv($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 69why, one step back
69

TweaksSindre Sorhusbefore adoption698a1b8

line 70why, one step back
70const testMergeMultiple = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 71why, one step back
71 const {stdout} = await execaMethod({env: {FOO: 'baz'}})({env: {BAR: 'bar'}})(PRINT_ENV_PATH, {env: {FOO: 'foo'}});

TweaksSindre Sorhusbefore adoption698a1b8

line 72why, one step back
72 assert.equal(stdout, 'foo\nbar');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 73–74why, one step back
73};
74

TweaksSindre Sorhusbefore adoption698a1b8

lines 75–79why, one step back
75test('execa() bound options are merged multiple times', () => testMergeMultiple(execa));
76test('execaSync() bound options are merged multiple times', () => testMergeMultiple(execaSync));77test('execaNode() bound options are merged multiple times', () => testMergeMultiple(execaNode));78test('$ bound options are merged multiple times', () => testMergeMultiple($));79test('$.sync bound options are merged multiple times', () => testMergeMultiple($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 80why, one step back
80

TweaksSindre Sorhusbefore adoption698a1b8

lines 81–84why, one step back
81const testMergeFdSpecific = async execaMethod => {
82 const {isMaxBuffer, shortMessage} = await assertRejects(execaMethod({maxBuffer: {stdout: 1}})(NOOP_PATH, [foobarString], {maxBuffer: {stderr: 100}}));83 assert.equal(isMaxBuffer, true);84 assert.ok(shortMessage.includes('Command\'s stdout was larger than 1'));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 85–86why, one step back
85};
86

TweaksSindre Sorhusbefore adoption698a1b8

lines 87–89why, one step back
87test('execa() bound options merge fd-specific ones', () => testMergeFdSpecific(execa));
88test('execaNode() bound options merge fd-specific ones', () => testMergeFdSpecific(execaNode));89test('$ bound options merge fd-specific ones', () => testMergeFdSpecific($));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 90why, one step back
90

TweaksSindre Sorhusbefore adoption698a1b8

line 91why, one step back
91const testMergeEnvUndefined = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 92why, one step back
92 const {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: undefined}});

TweaksSindre Sorhusbefore adoption698a1b8

line 93why, one step back
93 assert.equal(stdout, 'foo\nundefined');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 94–95why, one step back
94};
95

TweaksSindre Sorhusbefore adoption698a1b8

lines 96–100why, one step back
96test('execa() bound options are merged even if undefined', () => testMergeEnvUndefined(execa));
97test('execaSync() bound options are merged even if undefined', () => testMergeEnvUndefined(execaSync));98test('execaNode() bound options are merged even if undefined', () => testMergeEnvUndefined(execaNode));99test('$ bound options are merged even if undefined', () => testMergeEnvUndefined($));100test('$.sync bound options are merged even if undefined', () => testMergeEnvUndefined($.sync));

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 101why, one step back
101

TweaksSindre Sorhusbefore adoption698a1b8

line 102why, one step back
102const testMergeSpecific = async execaMethod => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 103why, one step back
103 const {stdout} = await execaMethod({stdout: {transform: uppercaseGenerator().transform, objectMode: true}})(NOOP_PATH, {stdout: {transform: uppercaseGenerator().transform}});

TweaksSindre Sorhusbefore adoption698a1b8

line 104why, one step back
104 assert.equal(stdout, foobarUppercase);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 105–106why, one step back
105};
106

TweaksSindre Sorhusbefore adoption698a1b8

lines 107–111why, one step back
107test('execa() bound options only merge specific ones', () => testMergeSpecific(execa));
108test('execaSync() bound options only merge specific ones', () => testMergeSpecific(execaSync));109test('execaNode() bound options only merge specific ones', () => testMergeSpecific(execaNode));110test('$ bound options only merge specific ones', () => testMergeSpecific($));111test('$.sync bound options only merge specific ones', () => testMergeSpecific($.sync));