diff --git a/src/utils/__tests__/config.test.ts b/src/utils/__tests__/config.test.ts index 35b4c68..2ec9be7 100644 --- a/src/utils/__tests__/config.test.ts +++ b/src/utils/__tests__/config.test.ts @@ -19,6 +19,7 @@ import { } from '../../types/Settings'; const MOCK_HOME_DIR = '/tmp/ccstatusline-config-test-home'; +const ORIGINAL_CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR; let loadSettings: () => Promise; let saveSettings: (settings: Settings) => Promise; @@ -34,6 +35,10 @@ function getSettingsPaths(): { configDir: string; settingsPath: string; backupPa }; } +function getClaudeConfigDir(): string { + return path.join(MOCK_HOME_DIR, '.claude'); +} + describe('config utilities', () => { beforeAll(async () => { const configModule = await import('../config'); @@ -44,6 +49,7 @@ describe('config utilities', () => { beforeEach(() => { fs.rmSync(MOCK_HOME_DIR, { recursive: true, force: true }); + process.env.CLAUDE_CONFIG_DIR = getClaudeConfigDir(); const { settingsPath } = getSettingsPaths(); initConfigPath(settingsPath); consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined); @@ -55,6 +61,11 @@ describe('config utilities', () => { afterAll(() => { fs.rmSync(MOCK_HOME_DIR, { recursive: true, force: true }); + if (ORIGINAL_CLAUDE_CONFIG_DIR === undefined) { + delete process.env.CLAUDE_CONFIG_DIR; + } else { + process.env.CLAUDE_CONFIG_DIR = ORIGINAL_CLAUDE_CONFIG_DIR; + } initConfigPath(); }); @@ -160,4 +171,4 @@ describe('config utilities', () => { expect(saved.version).toBe(CURRENT_VERSION); expect(consoleErrorSpy).not.toHaveBeenCalled(); }); -}); \ No newline at end of file +});