Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

os-jank.test.ts

39 lines991 Bytes

1import { describe, expect, it, vi } from "vitest";
2​
3import { fixPath } from "./os-jank";
4​
5describe("fixPath", () => {
6 it("hydrates PATH on linux using the resolved login shell", () => {
7 const env: NodeJS.ProcessEnv = {
8 SHELL: "/bin/zsh",
9 PATH: "/usr/bin",
10 };
11 const readPath = vi.fn(() => "/opt/homebrew/bin:/usr/bin");
12​
13 fixPath({
14 env,
15 platform: "linux",
16 readPath,
17 });
18​
19 expect(readPath).toHaveBeenCalledWith("/bin/zsh");
20 expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
21 });
22​
23 it("does nothing outside macOS and linux even when SHELL is set", () => {
24 const env: NodeJS.ProcessEnv = {
25 SHELL: "C:/Program Files/Git/bin/bash.exe",
26 PATH: "C:\\Windows\\System32",
27 };
28 const readPath = vi.fn(() => "/usr/local/bin:/usr/bin");
29​
30 fixPath({
31 env,
32 platform: "win32",
33 readPath,
34 });
35​
36 expect(readPath).not.toHaveBeenCalled();
37 expect(env.PATH).toBe("C:\\Windows\\System32");
38 });
39});