import { describe, it, expect, vi } from "vitest"; import { Trader } from "../trader"; import type { AnalystReport, DebateRound } from "../../types/agents"; describe("Trader", () => { const mockClient = { createChatCompletion: vi.fn().mockResolvedValue({ choices: [{ message: { content: '{"action": "buy", "confidence": 0.75, "reasoning": "Strong bullish signals"}' } }], }), }; const mockReports: AnalystReport[] = [ { analyst: "fundamentals", report: "Strong earnings growth", signal: { agent: "fundamentals", signal: "bullish", confidence: 0.8, reasoning: "Revenue up 20%", timestamp: "2024-01-01", }, }, ]; const mockDebates: DebateRound[] = [ { bullishView: "Strong fundamentals", bearishView: "Market volatility", researcher: "bullish", }, ]; it("should make trading decision", async () => { const trader = new Trader(mockClient as any); const decision = await trader.decide("AAPL", mockReports, mockDebates); expect(decision.action).toBe("buy"); }); });