mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
chore: fix folder trust tests (#10636)
This commit is contained in:
@@ -17,8 +17,9 @@ vi.mock('../../utils/processUtils.js', () => ({
|
||||
const mockedExit = vi.hoisted(() => vi.fn());
|
||||
const mockedCwd = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('process', async () => {
|
||||
const actual = await vi.importActual('process');
|
||||
vi.mock('node:process', async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import('node:process')>('node:process');
|
||||
return {
|
||||
...actual,
|
||||
exit: mockedExit,
|
||||
|
||||
@@ -11,14 +11,19 @@ import type { LoadedSettings } from '../../config/settings.js';
|
||||
import { FolderTrustChoice } from '../components/FolderTrustDialog.js';
|
||||
import type { LoadedTrustedFolders } from '../../config/trustedFolders.js';
|
||||
import { TrustLevel } from '../../config/trustedFolders.js';
|
||||
import * as process from 'node:process';
|
||||
|
||||
import * as trustedFolders from '../../config/trustedFolders.js';
|
||||
|
||||
vi.mock('process', () => ({
|
||||
cwd: vi.fn(),
|
||||
platform: 'linux',
|
||||
}));
|
||||
const mockedCwd = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('node:process', async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import('node:process')>('node:process');
|
||||
return {
|
||||
...actual,
|
||||
cwd: mockedCwd,
|
||||
platform: 'linux',
|
||||
};
|
||||
});
|
||||
|
||||
describe('useFolderTrust', () => {
|
||||
let mockSettings: LoadedSettings;
|
||||
@@ -47,7 +52,7 @@ describe('useFolderTrust', () => {
|
||||
.spyOn(trustedFolders, 'loadTrustedFolders')
|
||||
.mockReturnValue(mockTrustedFolders);
|
||||
isWorkspaceTrustedSpy = vi.spyOn(trustedFolders, 'isWorkspaceTrusted');
|
||||
(process.cwd as vi.Mock).mockReturnValue('/test/path');
|
||||
mockedCwd.mockReturnValue('/test/path');
|
||||
onTrustChange = vi.fn();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user