The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it, onTestFinished, vi } from "vite-plus/test"; |
| 2 | |
| 3 | import { unsetInheritedGitRepositoryEnv } from "./gitRepositoryEnv.ts"; |
| 4 | |
| 5 | describe("git test setup", () => { |
| 6 | it("starts tests without the repository selectors git exported to the run", async () => { |
| 7 | onTestFinished(() => { |
| 8 | vi.unstubAllEnvs(); |
| 9 | }); |
| 10 | vi.stubEnv("GIT_DIR", "/repo/.git/worktrees/wt"); |
| 11 | vi.stubEnv("GIT_INDEX_FILE", "/repo/.git/worktrees/wt/index"); |
| 12 | vi.stubEnv("GIT_EDITOR", "true"); |
| 13 | |
| 14 | vi.resetModules(); |
| 15 | await import("./gitEnv.ts"); |
| 16 | |
| 17 | expect(process.env).not.toHaveProperty("GIT_DIR"); |
| 18 | expect(process.env).not.toHaveProperty("GIT_INDEX_FILE"); |
| 19 | expect(process.env.GIT_EDITOR).toBe("true"); |
| 20 | }); |
| 21 | |
| 22 | it("unsets a selector under the spelling Windows passed it in", () => { |
| 23 | const inherited = { Git_Dir: "C:\\repo\\.git", GIT_EDITOR: "true", PATH: "C:\\bin" }; |
| 24 | expect(Object.keys(unsetInheritedGitRepositoryEnv(inherited, "win32"))).toEqual(["Git_Dir"]); |
| 25 | expect(Object.keys(unsetInheritedGitRepositoryEnv(inherited, "linux"))).toEqual([]); |
| 26 | }); |
| 27 | }); |