Skip to content

Commit c738d0b

Browse files
zkochanclaude
andcommitted
test: add Windows test for proxyVarSubDir
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d593920 commit c738d0b

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

os/env/path-extender-windows/path-extender-windows.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,56 @@ HKEY_CURRENT_USER\\Environment
148148
expect(execa).toHaveBeenNthCalledWith(7, 'reg', ['delete' ,regKey, '/v', 'REFRESH_ENV_VARS', '/f'], { windowsHide: false })
149149
})
150150

151+
test('successful first time installation with proxyVarSubDir', async () => {
152+
const currentPathInRegistry = '%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;%USERPROFILE%\\.config\\etc;'
153+
154+
execa['mockResolvedValueOnce']({
155+
failed: false,
156+
stdout: '活动代码页: 936',
157+
}).mockResolvedValueOnce({
158+
failed: false,
159+
stdout: '',
160+
}).mockResolvedValueOnce({
161+
failed: false,
162+
stdout: `
163+
HKEY_CURRENT_USER\\Environment
164+
Path REG_EXPAND_SZ ${currentPathInRegistry}
165+
`,
166+
}).mockResolvedValueOnce({
167+
failed: false,
168+
stdout: 'PNPM_HOME ENV VAR SET',
169+
}).mockResolvedValueOnce({
170+
failed: false,
171+
stdout: 'setx PNPM_HOME',
172+
}).mockResolvedValueOnce({
173+
failed: false,
174+
stdout: 'setx PNPM_HOME',
175+
}).mockResolvedValue({
176+
failed: true,
177+
stderr: 'UNEXPECTED',
178+
})
179+
180+
const pnpmHomeDir = tempDir(false)
181+
const pnpmHomeDirNormalized = path.normalize(pnpmHomeDir)
182+
const report = await addDirToWindowsEnvPath(pnpmHomeDir, { proxyVarName: 'PNPM_HOME', proxyVarSubDir: 'bin' })
183+
184+
expect(report).toStrictEqual([
185+
{
186+
action: 'updated',
187+
variable: 'PNPM_HOME',
188+
oldValue: undefined,
189+
newValue: pnpmHomeDirNormalized,
190+
},
191+
{
192+
action: 'updated',
193+
variable: 'Path',
194+
oldValue: currentPathInRegistry,
195+
newValue: `%PNPM_HOME%\\bin;${currentPathInRegistry}`,
196+
},
197+
])
198+
expect(execa).toHaveBeenNthCalledWith(5, 'reg', ['add', regKey, '/v', 'Path', '/t', 'REG_EXPAND_SZ', '/d', `%PNPM_HOME%\\bin;${currentPathInRegistry}`, '/f'], { windowsHide: false })
199+
})
200+
151201
test('successful first time installation when no additional env variable is used', async () => {
152202
const currentPathInRegistry = '%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;%USERPROFILE%\\.config\\etc;'
153203

0 commit comments

Comments
 (0)