bind.js
This file
Path
test/methods/bind.js
111 lines · 5.6 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
line 2why, one step back2import path from 'node:path';TweaksSindre Sorhusbefore adoption698a1b8
lines 3–4why, one step back3import test from 'node:test';4import {assertRejects} from '../helpers/assert.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 5–16why, one step back5import {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();16Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0
lines 17–18why, one step back17const 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 back19TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20const testBindOptions = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 21why, one step back21 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);TweaksSindre Sorhusbefore adoption698a1b8
line 22why, one step back22 assert.equal(stdout, `${foobarString}\n`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 23–24why, one step back23};24TweaksSindre Sorhusbefore adoption698a1b8
lines 25–27why, one step back25test('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 back28TweaksSindre Sorhusbefore adoption698a1b8
line 29why, one step back29const testBindOptionsSync = execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 30why, one step back30 const {stdout} = execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);TweaksSindre Sorhusbefore adoption698a1b8
line 31why, one step back31 assert.equal(stdout, `${foobarString}\n`);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 32–33why, one step back32};33TweaksSindre Sorhusbefore adoption698a1b8
lines 34–35why, one step back34test('execaSync() can bind options', () => testBindOptionsSync(execaSync));35test('$.sync can bind options', () => testBindOptionsSync($.sync));100% test coverage (#1018)ehmickybefore adoption9f65b86
line 36why, one step back36TweaksSindre Sorhusbefore adoption698a1b8
line 37why, one step back37const testBindPriority = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 38why, one step back38 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: true});TweaksSindre Sorhusbefore adoption698a1b8
line 39why, one step back39 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 40–41why, one step back40};41TweaksSindre Sorhusbefore adoption698a1b8
lines 42–46why, one step back42test('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 back47TweaksSindre Sorhusbefore adoption698a1b8
line 48why, one step back48const testBindUndefined = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 49why, one step back49 const {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: undefined});TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50 assert.equal(stdout, foobarString);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 51–52why, one step back51};52TweaksSindre Sorhusbefore adoption698a1b8
lines 53–57why, one step back53test('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 back58TweaksSindre Sorhusbefore adoption698a1b8
line 59why, one step back59const testMergeEnv = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 60why, one step back60 const {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: 'bar'}});TweaksSindre Sorhusbefore adoption698a1b8
line 61why, one step back61 assert.equal(stdout, 'foo\nbar');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 62–63why, one step back62};63TweaksSindre Sorhusbefore adoption698a1b8
lines 64–68why, one step back64test('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 back69TweaksSindre Sorhusbefore adoption698a1b8
line 70why, one step back70const testMergeMultiple = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 71why, one step back71 const {stdout} = await execaMethod({env: {FOO: 'baz'}})({env: {BAR: 'bar'}})(PRINT_ENV_PATH, {env: {FOO: 'foo'}});TweaksSindre Sorhusbefore adoption698a1b8
line 72why, one step back72 assert.equal(stdout, 'foo\nbar');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 73–74why, one step back73};74TweaksSindre Sorhusbefore adoption698a1b8
lines 75–79why, one step back75test('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 back80TweaksSindre Sorhusbefore adoption698a1b8
lines 81–84why, one step back81const 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 back85};86TweaksSindre Sorhusbefore adoption698a1b8
lines 87–89why, one step back87test('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 back90TweaksSindre Sorhusbefore adoption698a1b8
line 91why, one step back91const testMergeEnvUndefined = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 92why, one step back92 const {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: undefined}});TweaksSindre Sorhusbefore adoption698a1b8
line 93why, one step back93 assert.equal(stdout, 'foo\nundefined');100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 94–95why, one step back94};95TweaksSindre Sorhusbefore adoption698a1b8
lines 96–100why, one step back96test('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 back101TweaksSindre Sorhusbefore adoption698a1b8
line 102why, one step back102const testMergeSpecific = async execaMethod => {100% test coverage (#1018)ehmickybefore adoption9f65b86
line 103why, one step back103 const {stdout} = await execaMethod({stdout: {transform: uppercaseGenerator().transform, objectMode: true}})(NOOP_PATH, {stdout: {transform: uppercaseGenerator().transform}});TweaksSindre Sorhusbefore adoption698a1b8
line 104why, one step back104 assert.equal(stdout, foobarUppercase);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 105–106why, one step back105};106TweaksSindre Sorhusbefore adoption698a1b8
lines 107–111why, one step back107test('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));