Files
AITrader/app/components/__tests__/TradingViewChart.test.tsx
T
henry 2e22fd5635 feat: add stock detail page with chart, position, and orders
- Add /api/alpaca/orders endpoint for order history
- Add TradingView chart component for candlestick visualization
- Add /analyze/:ticker route with position and orders display
- Make ticker cells in analyze page clickable for navigation
2026-05-14 11:00:35 +02:00

36 lines
1.1 KiB
TypeScript

/// <reference types="vitest" />
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { render, screen } from "@testing-library/react";
import TradingViewChart from "../TradingViewChart";
// Mock lightweight-charts
vi.mock("lightweight-charts", () => ({
createChart: vi.fn(() => ({
addSeries: vi.fn(() => ({
setData: vi.fn(),
})),
remove: vi.fn(),
})),
CandlestickSeries: {},
}));
describe("TradingViewChart", () => {
it("renders the ticker symbol as heading", () => {
render(<TradingViewChart ticker="AAPL" />);
expect(screen.getByText("AAPL Price Chart")).toBeInTheDocument();
});
it("renders without data prop", () => {
render(<TradingViewChart ticker="MSFT" />);
expect(screen.getByText("MSFT Price Chart")).toBeInTheDocument();
});
it("renders with data prop", () => {
const data = [
{ time: "2024-01-01", open: 100, high: 110, low: 95, close: 105 },
{ time: "2024-01-02", open: 105, high: 115, low: 100, close: 110 },
];
render(<TradingViewChart ticker="GOOGL" data={data} />);
expect(screen.getByText("GOOGL Price Chart")).toBeInTheDocument();
});
});