Fix tests

This commit is contained in:
cte 2025-02-24 13:07:00 -08:00
parent d94067aba8
commit a130e656f1
3 changed files with 15 additions and 8 deletions

View file

@ -1,9 +1,11 @@
import { GlamaHandler } from "../glama"
import { ApiHandlerOptions } from "../../../shared/api"
import OpenAI from "openai"
// npx jest src/api/providers/__tests__/glama.test.ts
import { Anthropic } from "@anthropic-ai/sdk"
import axios from "axios"
import { GlamaHandler } from "../glama"
import { ApiHandlerOptions } from "../../../shared/api"
// Mock OpenAI client
const mockCreate = jest.fn()
const mockWithResponse = jest.fn()
@ -71,8 +73,8 @@ describe("GlamaHandler", () => {
beforeEach(() => {
mockOptions = {
apiModelId: "anthropic/claude-3-5-sonnet",
glamaModelId: "anthropic/claude-3-5-sonnet",
apiModelId: "anthropic/claude-3-7-sonnet",
glamaModelId: "anthropic/claude-3-7-sonnet",
glamaApiKey: "test-api-key",
}
handler = new GlamaHandler(mockOptions)

View file

@ -1,3 +1,5 @@
// npx jest src/api/providers/__tests__/openrouter.test.ts
import { OpenRouterHandler } from "../openrouter"
import { ApiHandlerOptions, ModelInfo } from "../../../shared/api"
import OpenAI from "openai"
@ -55,7 +57,7 @@ describe("OpenRouterHandler", () => {
const handler = new OpenRouterHandler({})
const result = handler.getModel()
expect(result.id).toBe("anthropic/claude-3.5-sonnet:beta")
expect(result.id).toBe("anthropic/claude-3.7-sonnet")
expect(result.info.supportsPromptCache).toBe(true)
})

View file

@ -1,7 +1,10 @@
import { VertexHandler } from "../vertex"
// npx jest src/api/providers/__tests__/vertex.test.ts
import { Anthropic } from "@anthropic-ai/sdk"
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk"
import { VertexHandler } from "../vertex"
// Mock Vertex SDK
jest.mock("@anthropic-ai/vertex-sdk", () => ({
AnthropicVertex: jest.fn().mockImplementation(() => ({
@ -289,7 +292,7 @@ describe("VertexHandler", () => {
vertexRegion: "us-central1",
})
const modelInfo = invalidHandler.getModel()
expect(modelInfo.id).toBe("claude-3-5-sonnet-v2@20241022") // Default model
expect(modelInfo.id).toBe("claude-3-7-sonnet@20250219") // Default model
})
})
})