Skip to content

Commit dbb2567

Browse files
committed
test: check preset helpers
1 parent 18e8e13 commit dbb2567

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

src/core.ts

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export function usePwsh() {
127127
export function useBash() {
128128
$.shell = which.sync('bash')
129129
$.prefix = 'set -euo pipefail;'
130+
$.postfix = ''
130131
$.quote = quote
131132
}
132133

test/core.test.js

+33-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
import assert from 'node:assert'
16-
import { test, describe } from 'node:test'
16+
import { test, describe, before, after } from 'node:test'
1717
import { inspect } from 'node:util'
1818
import { basename } from 'node:path'
1919
import { Readable, Writable } from 'node:stream'
@@ -584,15 +584,38 @@ describe('core', () => {
584584
assert.ok(ok, 'Expected failure!')
585585
})
586586

587-
test('usePwsh() sets proper defaults', () => {
587+
describe('presets', () => {
588588
const originalWhichSync = which.sync
589-
which.sync = (bin) => (bin === 'pwsh' ? 'pwsh' : originalWhichSync(bin))
590-
usePwsh()
591-
assert.equal($.shell, 'pwsh')
592-
assert.equal($.prefix, '')
593-
assert.equal($.postfix, '; exit $LastExitCode')
594-
assert.equal($.quote, quotePowerShell)
595-
which.sync = originalWhichSync
596-
useBash()
589+
before(() => {
590+
which.sync = (bin) => bin
591+
})
592+
after(() => {
593+
which.sync = originalWhichSync
594+
useBash()
595+
})
596+
597+
test('usePwsh()', () => {
598+
usePwsh()
599+
assert.equal($.shell, 'pwsh')
600+
assert.equal($.prefix, '')
601+
assert.equal($.postfix, '; exit $LastExitCode')
602+
assert.equal($.quote, quotePowerShell)
603+
})
604+
605+
test('usePowerShell()', () => {
606+
usePowerShell()
607+
assert.equal($.shell, 'powershell.exe')
608+
assert.equal($.prefix, '')
609+
assert.equal($.postfix, '; exit $LastExitCode')
610+
assert.equal($.quote, quotePowerShell)
611+
})
612+
613+
test('useBash()', () => {
614+
useBash()
615+
assert.equal($.shell, 'bash')
616+
assert.equal($.prefix, 'set -euo pipefail;')
617+
assert.equal($.postfix, '')
618+
assert.equal($.quote, quote)
619+
})
597620
})
598621
})

test/fixtures/js-project/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)