summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuki Okita <[email protected]>2025-07-13 04:13:22 +0900
committerGitHub <[email protected]>2025-07-12 19:13:22 +0000
commit890982a811e22de9525148e6c28f39bfbf10a49a (patch)
treeeb5dc497b5266a9171bd6087b70e970590c36baf
parentb3cbde5cf396026635675aff5d7bc6fd30e1553d (diff)
fix(core): make the commented-out test workable (#3885)
-rw-r--r--packages/core/src/config/config.test.ts54
1 files changed, 30 insertions, 24 deletions
diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts
index c9debdbe..c9965e87 100644
--- a/packages/core/src/config/config.test.ts
+++ b/packages/core/src/config/config.test.ts
@@ -12,7 +12,11 @@ import {
DEFAULT_TELEMETRY_TARGET,
DEFAULT_OTLP_ENDPOINT,
} from '../telemetry/index.js';
-
+import {
+ AuthType,
+ createContentGeneratorConfig,
+} from '../core/contentGenerator.js';
+import { GeminiClient } from '../core/client.js';
import { loadServerHierarchicalMemory } from '../utils/memoryDiscovery.js';
// Mock dependencies that might be called during Config construction or createServerConfig
@@ -59,7 +63,7 @@ vi.mock('../core/contentGenerator.js', async (importOriginal) => {
vi.mock('../core/client.js', () => ({
GeminiClient: vi.fn().mockImplementation(() => ({
- // Mock any methods on GeminiClient that might be used.
+ initialize: vi.fn().mockResolvedValue(undefined),
})),
}));
@@ -104,31 +108,33 @@ describe('Server Config (config.ts)', () => {
vi.clearAllMocks();
});
- // i can't get vi mocking to import in core. only in cli. can't fix it now.
- // describe('refreshAuth', () => {
- // it('should refresh auth and update config', async () => {
- // const config = new Config(baseParams);
- // const newModel = 'gemini-ultra';
- // const authType = AuthType.USE_GEMINI;
- // const mockContentConfig = {
- // model: newModel,
- // apiKey: 'test-key',
- // };
+ describe('refreshAuth', () => {
+ it('should refresh auth and update config', async () => {
+ const config = new Config(baseParams);
+ const authType = AuthType.USE_GEMINI;
+ const newModel = 'gemini-flash';
+ const mockContentConfig = {
+ model: newModel,
+ apiKey: 'test-key',
+ };
- // (createContentGeneratorConfig as vi.Mock).mockResolvedValue(
- // mockContentConfig,
- // );
+ (createContentGeneratorConfig as Mock).mockResolvedValue(
+ mockContentConfig,
+ );
- // await config.refreshAuth(authType);
+ await config.refreshAuth(authType);
- // expect(createContentGeneratorConfig).toHaveBeenCalledWith(
- // newModel,
- // authType,
- // );
- // expect(config.getContentGeneratorConfig()).toEqual(mockContentConfig);
- // expect(GeminiClient).toHaveBeenCalledWith(config);
- // });
- // });
+ expect(createContentGeneratorConfig).toHaveBeenCalledWith(
+ MODEL, // Should be called with the original model 'gemini-pro'
+ authType,
+ );
+ // Verify that contentGeneratorConfig is updated with the new model
+ expect(config.getContentGeneratorConfig()).toEqual(mockContentConfig);
+ expect(config.getContentGeneratorConfig().model).toBe(newModel);
+ expect(config.getModel()).toBe(newModel); // getModel() should return the updated model
+ expect(GeminiClient).toHaveBeenCalledWith(config);
+ });
+ });
it('Config constructor should store userMemory correctly', () => {
const config = new Config(baseParams);