This commit is contained in:
Tommaso Sciortino
2025-12-03 11:07:23 -08:00
committed by GitHub
parent 8d4082ef2e
commit 00705b14bd
3 changed files with 10 additions and 3 deletions
@@ -24,6 +24,10 @@ vi.mock('ink', async () => {
}; };
}); });
vi.mock('./CliSpinner.js', () => ({
CliSpinner: () => 'Spinner',
}));
describe('GeminiRespondingSpinner', () => { describe('GeminiRespondingSpinner', () => {
const mockUseStreamingContext = vi.mocked(useStreamingContext); const mockUseStreamingContext = vi.mocked(useStreamingContext);
const mockUseIsScreenReaderEnabled = vi.mocked(useIsScreenReaderEnabled); const mockUseIsScreenReaderEnabled = vi.mocked(useIsScreenReaderEnabled);
@@ -33,6 +33,9 @@ describe('sandboxUtils', () => {
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks(); vi.clearAllMocks();
process.env = { ...originalEnv }; process.env = { ...originalEnv };
// Clean up these env vars that might affect tests
delete process.env['NODE_ENV'];
delete process.env['DEBUG'];
}); });
afterEach(() => { afterEach(() => {
+3 -3
View File
@@ -6,7 +6,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { getCliVersion } from './version.js'; import { getCliVersion } from './version.js';
import * as core from '@google/gemini-cli-core'; import { getPackageJson } from '@google/gemini-cli-core';
vi.mock('@google/gemini-cli-core', () => ({ vi.mock('@google/gemini-cli-core', () => ({
getPackageJson: vi.fn(), getPackageJson: vi.fn(),
@@ -18,7 +18,7 @@ describe('version', () => {
beforeEach(() => { beforeEach(() => {
vi.resetModules(); vi.resetModules();
process.env = { ...originalEnv }; process.env = { ...originalEnv };
vi.mocked(core.getPackageJson).mockResolvedValue({ version: '1.0.0' }); vi.mocked(getPackageJson).mockResolvedValue({ version: '1.0.0' });
}); });
afterEach(() => { afterEach(() => {
@@ -39,7 +39,7 @@ describe('version', () => {
it('should return "unknown" if package.json is not found and CLI_VERSION is not set', async () => { it('should return "unknown" if package.json is not found and CLI_VERSION is not set', async () => {
delete process.env['CLI_VERSION']; delete process.env['CLI_VERSION'];
vi.mocked(core.getPackageJson).mockResolvedValue(undefined); vi.mocked(getPackageJson).mockResolvedValue(undefined);
const version = await getCliVersion(); const version = await getCliVersion();
expect(version).toBe('unknown'); expect(version).toBe('unknown');
}); });