feat(settings): add settings route and API updates\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -71,6 +71,43 @@ describe("TradingViewChart", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("shows current price when provided via prop", () => {
|
||||
render(<TradingViewChart ticker="PRC" currentPrice={123.456} />);
|
||||
expect(screen.getByTestId("current-price")).toHaveTextContent("$123.46");
|
||||
});
|
||||
|
||||
it("derives current price from last data point when currentPrice prop missing", () => {
|
||||
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="DER" data={data} />);
|
||||
expect(screen.getByTestId("current-price")).toHaveTextContent("$110.00");
|
||||
});
|
||||
|
||||
it("updates when price stream emits", async () => {
|
||||
// create a simple priceStream that stores callback
|
||||
let cb: ((p: number) => void) | undefined;
|
||||
const unsubscribe = vi.fn();
|
||||
const priceStream = {
|
||||
subscribe: (c: (p: number) => void) => {
|
||||
cb = c;
|
||||
return unsubscribe;
|
||||
},
|
||||
} as any;
|
||||
|
||||
render(<TradingViewChart ticker="STR" priceStream={priceStream} />);
|
||||
expect(screen.queryByTestId("current-price")).toBeNull();
|
||||
|
||||
// emit a price
|
||||
if (cb) cb(200);
|
||||
|
||||
// wait a tick for state update
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
|
||||
expect(screen.getByTestId("current-price")).toHaveTextContent("$200.00");
|
||||
});
|
||||
|
||||
it("creates candlestick series with explicit colors", () => {
|
||||
const mockAddSeries = vi.fn();
|
||||
mockCreateChart.mockReturnValue({
|
||||
|
||||
Reference in New Issue
Block a user