11// npx jest src/api/providers/__tests__/openrouter.test.ts
22
3- import axios from "axios"
43import { Anthropic } from "@anthropic-ai/sdk"
54import OpenAI from "openai"
65
76import { OpenRouterHandler } from "../openrouter"
8- import { ApiHandlerOptions , ModelInfo } from "../../../shared/api"
7+ import { ApiHandlerOptions } from "../../../shared/api"
98
109// Mock dependencies
1110jest . mock ( "openai" )
12- jest . mock ( "axios" )
1311jest . mock ( "delay" , ( ) => jest . fn ( ( ) => Promise . resolve ( ) ) )
1412
15- const mockOpenRouterModelInfo : ModelInfo = {
16- maxTokens : 1000 ,
17- contextWindow : 2000 ,
18- supportsPromptCache : false ,
19- inputPrice : 0.01 ,
20- outputPrice : 0.02 ,
21- }
22-
2313describe ( "OpenRouterHandler" , ( ) => {
2414 const mockOptions : ApiHandlerOptions = {
2515 openRouterApiKey : "test-key" ,
2616 openRouterModelId : "anthropic/claude-3.7-sonnet" ,
2717 }
2818
29- beforeEach ( ( ) => {
30- jest . clearAllMocks ( )
31- } )
19+ beforeEach ( ( ) => jest . clearAllMocks ( ) )
3220
3321 it ( "initializes with correct options" , ( ) => {
3422 const handler = new OpenRouterHandler ( mockOptions )
@@ -183,7 +171,6 @@ describe("OpenRouterHandler", () => {
183171 ; ( OpenAI as jest . MockedClass < typeof OpenAI > ) . prototype . chat = {
184172 completions : { create : mockCreate } ,
185173 } as any
186- ; ( axios . get as jest . Mock ) . mockResolvedValue ( { data : { data : { } } } )
187174
188175 await handler . createMessage ( "test" , [ ] ) . next ( )
189176
@@ -209,7 +196,6 @@ describe("OpenRouterHandler", () => {
209196 ; ( OpenAI as jest . MockedClass < typeof OpenAI > ) . prototype . chat = {
210197 completions : { create : mockCreate } ,
211198 } as any
212- ; ( axios . get as jest . Mock ) . mockResolvedValue ( { data : { data : { } } } )
213199
214200 const messages : Anthropic . Messages . MessageParam [ ] = [
215201 { role : "user" , content : "message 1" } ,
0 commit comments