Files
oh-my-opencode/src/shared/claude-config-dir.test.ts
T
Matan Kushner b98d474812 test: remove redundant local env restoration
The global test-setup.ts (preloaded via bunfig.toml) already snapshots
process.env in beforeEach and restores it in afterEach for every test.
Per-file env tracking is duplicate work and creates four different
patterns for the same problem.

Affected files:
- src/shared/claude-config-dir.test.ts (beforeEach/afterEach pair)
- src/shared/plugin-command-discovery.test.ts (ENV_KEYS + envSnapshot)
- src/features/claude-code-agent-loader/loader.test.ts (try/finally)
- src/features/skill-mcp-manager/connection-env-vars.test.ts (ORIGINAL_ENV)
2026-05-04 20:11:50 +09:00

47 lines
1.2 KiB
TypeScript

import { describe, test, expect } from "bun:test"
import { homedir } from "node:os"
import { join } from "node:path"
import { getClaudeConfigDir } from "./claude-config-dir"
describe("getClaudeConfigDir", () => {
test("returns CLAUDE_CONFIG_DIR when env var is set", () => {
process.env.CLAUDE_CONFIG_DIR = "/custom/claude/path"
const result = getClaudeConfigDir()
expect(result).toBe("/custom/claude/path")
})
test("returns ~/.claude when env var is not set", () => {
delete process.env.CLAUDE_CONFIG_DIR
const result = getClaudeConfigDir()
expect(result).toBe(join(homedir(), ".claude"))
})
test("returns ~/.claude when env var is empty string", () => {
process.env.CLAUDE_CONFIG_DIR = ""
const result = getClaudeConfigDir()
expect(result).toBe(join(homedir(), ".claude"))
})
test("handles absolute paths with trailing slash", () => {
process.env.CLAUDE_CONFIG_DIR = "/custom/path/"
const result = getClaudeConfigDir()
expect(result).toBe("/custom/path/")
})
test("handles relative paths", () => {
process.env.CLAUDE_CONFIG_DIR = "./my-claude-config"
const result = getClaudeConfigDir()
expect(result).toBe("./my-claude-config")
})
})