Files
pnpm/env/system-node-version/test/getSystemNodeVersion.test.ts
T
2024-10-21 02:53:47 +02:00

22 lines
605 B
TypeScript

import { getSystemNodeVersionNonCached } from '../lib'
import * as execa from 'execa'
jest.mock('execa', () => ({
sync: jest.fn(() => ({
stdout: 'v10.0.0',
})),
}))
test('getSystemNodeVersion() executed from an executable pnpm CLI', () => {
// @ts-expect-error
process['pkg'] = {}
expect(getSystemNodeVersionNonCached()).toBe('v10.0.0')
expect(execa.sync).toHaveBeenCalledWith('node', ['--version'])
})
test('getSystemNodeVersion() from a non-executable pnpm CLI', () => {
// @ts-expect-error
delete process['pkg']
expect(getSystemNodeVersionNonCached()).toBe(process.version)
})