summaryrefslogtreecommitdiff
path: root/packages/server/src/core/client.test.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-05-30 18:25:47 -0700
committerGitHub <[email protected]>2025-05-30 18:25:47 -0700
commit21fba832d1b4ea7af43fb887d9b2b38fcf8210d0 (patch)
tree7200d2fac3a55c385e0a2dac34b5282c942364bc /packages/server/src/core/client.test.ts
parentc81148a0cc8489f657901c2cc7247c0834075e1a (diff)
Rename server->core (#638)
Diffstat (limited to 'packages/server/src/core/client.test.ts')
-rw-r--r--packages/server/src/core/client.test.ts89
1 files changed, 0 insertions, 89 deletions
diff --git a/packages/server/src/core/client.test.ts b/packages/server/src/core/client.test.ts
deleted file mode 100644
index 228701d8..00000000
--- a/packages/server/src/core/client.test.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * @license
- * Copyright 2025 Google LLC
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-
-import { Chat, GenerateContentResponse } from '@google/genai';
-
-// --- Mocks ---
-const mockChatCreateFn = vi.fn();
-const mockGenerateContentFn = vi.fn();
-
-vi.mock('@google/genai', async (importOriginal) => {
- const actual = await importOriginal<typeof import('@google/genai')>();
- const MockedGoogleGenerativeAI = vi
- .fn()
- .mockImplementation((/*...args*/) => ({
- chats: { create: mockChatCreateFn },
- models: { generateContent: mockGenerateContentFn },
- }));
- return {
- ...actual,
- GoogleGenerativeAI: MockedGoogleGenerativeAI,
- Chat: vi.fn(),
- Type: actual.Type ?? { OBJECT: 'OBJECT', STRING: 'STRING' },
- };
-});
-
-vi.mock('../config/config');
-vi.mock('./prompts');
-vi.mock('../utils/getFolderStructure', () => ({
- getFolderStructure: vi.fn().mockResolvedValue('Mock Folder Structure'),
-}));
-vi.mock('../utils/errorReporting', () => ({ reportError: vi.fn() }));
-vi.mock('../utils/nextSpeakerChecker', () => ({
- checkNextSpeaker: vi.fn().mockResolvedValue(null),
-}));
-vi.mock('../utils/generateContentResponseUtilities', () => ({
- getResponseText: (result: GenerateContentResponse) =>
- result.candidates?.[0]?.content?.parts?.map((part) => part.text).join('') ||
- undefined,
-}));
-
-describe('Gemini Client (client.ts)', () => {
- beforeEach(() => {
- vi.resetAllMocks();
- mockChatCreateFn.mockResolvedValue({} as Chat);
- mockGenerateContentFn.mockResolvedValue({
- candidates: [
- {
- content: {
- parts: [{ text: '{"key": "value"}' }],
- },
- },
- ],
- } as unknown as GenerateContentResponse);
- });
-
- afterEach(() => {
- vi.restoreAllMocks();
- });
-
- // NOTE: The following tests for startChat were removed due to persistent issues with
- // the @google/genai mock. Specifically, the mockChatCreateFn (representing instance.chats.create)
- // was not being detected as called by the GeminiClient instance.
- // This likely points to a subtle issue in how the GoogleGenerativeAI class constructor
- // and its instance methods are mocked and then used by the class under test.
- // For future debugging, ensure that the `this.client` in `GeminiClient` (which is an
- // instance of the mocked GoogleGenerativeAI) correctly has its `chats.create` method
- // pointing to `mockChatCreateFn`.
- // it('startChat should call getCoreSystemPrompt with userMemory and pass to chats.create', async () => { ... });
- // it('startChat should call getCoreSystemPrompt with empty string if userMemory is empty', async () => { ... });
-
- // NOTE: The following tests for generateJson were removed due to persistent issues with
- // the @google/genai mock, similar to the startChat tests. The mockGenerateContentFn
- // (representing instance.models.generateContent) was not being detected as called, or the mock
- // was not preventing an actual API call (leading to API key errors).
- // For future debugging, ensure `this.client.models.generateContent` in `GeminiClient` correctly
- // uses the `mockGenerateContentFn`.
- // it('generateJson should call getCoreSystemPrompt with userMemory and pass to generateContent', async () => { ... });
- // it('generateJson should call getCoreSystemPrompt with empty string if userMemory is empty', async () => { ... });
-
- // Add a placeholder test to keep the suite valid
- it('should have a placeholder test', () => {
- expect(true).toBe(true);
- });
-});