mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-26 02:51:59 -04:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import execa from 'execa'
|
|
import { setup } from '@pnpm/plugin-commands-setup'
|
|
|
|
jest.mock('execa')
|
|
|
|
let originalShell: string | undefined
|
|
let originalPlatform = ''
|
|
|
|
beforeAll(() => {
|
|
originalShell = process.env.SHELL
|
|
originalPlatform = process.platform
|
|
|
|
process.env.SHELL = ''
|
|
Object.defineProperty(process, 'platform', {
|
|
value: 'win32',
|
|
})
|
|
})
|
|
|
|
afterAll(() => {
|
|
process.env.SHELL = originalShell
|
|
Object.defineProperty(process, 'platform', {
|
|
value: originalPlatform,
|
|
})
|
|
})
|
|
|
|
const regKey = 'HKEY_CURRENT_USER\\Environment'
|
|
|
|
test('Environment PATH is not configured correctly', async () => {
|
|
execa['mockResolvedValueOnce']({
|
|
failed: false,
|
|
stdout: 'SOME KIND OF ERROR OR UNSUPPORTED RESPONSE FORMAT',
|
|
}).mockResolvedValue({
|
|
failed: true,
|
|
})
|
|
|
|
const output = await setup.handler({
|
|
pnpmHomeDir: __dirname,
|
|
})
|
|
|
|
expect(execa).toHaveBeenNthCalledWith(1, 'reg', ['query', regKey])
|
|
expect(output).toContain('Current PATH is not set. No changes to this environment variable are applied')
|
|
})
|