test: remove duplicated env lookup helper

This commit is contained in:
Peter Steinberger
2026-04-20 14:42:50 +01:00
parent 8a4332864b
commit 4f37a5d590

View File

@@ -3,19 +3,6 @@ import { withEnv } from "../test-utils/env.js";
import { decodeCapturedOutputBuffer, parseWindowsCodePage, sanitizeEnv } from "./invoke.js";
import { buildNodeInvokeResultParams } from "./runner.js";
function getEnvValueCaseInsensitive(
env: Record<string, string>,
expectedKey: string,
): string | undefined {
const direct = env[expectedKey];
if (direct !== undefined) {
return direct;
}
const upper = expectedKey.toUpperCase();
const actualKey = Object.keys(env).find((key) => key.toUpperCase() === upper);
return actualKey ? env[actualKey] : undefined;
}
describe("node-host sanitizeEnv", () => {
it("ignores PATH overrides", () => {
withEnv({ PATH: "/usr/bin" }, () => {
@@ -68,7 +55,7 @@ describe("node-host sanitizeEnv", () => {
it("preserves inherited non-portable Windows-style env keys", () => {
withEnv({ "ProgramFiles(x86)": "C:\\Program Files (x86)" }, () => {
const env = sanitizeEnv(undefined);
expect(getEnvValueCaseInsensitive(env, "ProgramFiles(x86)")).toBe("C:\\Program Files (x86)");
expect(env["ProgramFiles(x86)"]).toBe("C:\\Program Files (x86)");
});
});
});