import { describe, it, expect } from "vitest"; import { SentimentAnalyst } from "../sentiment"; import type { OpenRouterClient } from "../../lib/openrouter"; describe("SentimentAnalyst", () => { it("should analyze sentiment from headlines", async () => { const mockClient = { createChatCompletion: async () => ({ choices: [ { message: { content: '{"signal":"bullish","confidence":0.85,"reasoning":"Positive sentiment from news"}', }, }, ], }), } as unknown as OpenRouterClient; const analyst = new SentimentAnalyst(mockClient); const result = await analyst.analyze("AAPL", { headlines: ["Apple beats earnings", "New iPhone launch"], source: "news", }); expect(result.analyst).toBe("sentiment"); expect(result.signal.signal).toBe("bullish"); }); it("should use specified model", () => { const mockClient = {} as unknown as OpenRouterClient; const analyst = new SentimentAnalyst(mockClient, { model: "custom/model", }); expect(analyst.getModel()).toBe("custom/model"); }); });