Skip to content

Commit 6c3f2da

Browse files
WitMiaoclaude
andcommitted
test: fix CCR menu tests by properly mocking file system checks
- Add mock for existsSync from node:fs module - Ensure CCR config file existence check passes in tests - Mock returns true for CCR config file to enable menu options 2-6 - All 10 CCR menu tests now pass correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 76c93bd commit 6c3f2da

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/utils/tools/ccr-menu.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { describe, it, expect, vi, beforeEach } from 'vitest';
2+
import { existsSync } from 'node:fs';
23
import inquirer from 'inquirer';
34
import { showCcrMenu } from '../../../src/utils/tools/ccr-menu';
45
import * as ccrInstaller from '../../../src/utils/ccr/installer';
56
import * as ccrConfig from '../../../src/utils/ccr/config';
67
import * as ccrCommands from '../../../src/utils/ccr/commands';
78

9+
vi.mock('node:fs');
810
vi.mock('inquirer');
911
vi.mock('../../../src/utils/ccr/installer');
1012
vi.mock('../../../src/utils/ccr/config');
@@ -25,6 +27,9 @@ describe('CCR Menu', () => {
2527
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
2628
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
2729

30+
// Mock existsSync to return true for CCR config file
31+
vi.mocked(existsSync).mockReturnValue(true);
32+
2833
// Mock readCcrConfig to return a valid CCR config by default
2934
vi.mocked(ccrConfig.readCcrConfig).mockReturnValue({
3035
APIKEY: 'test-key',

0 commit comments

Comments
 (0)