Wrap StockDetail test in MemoryRouter to provide Link context; mock useLoaderData remains
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
||||||
import StockDetail from "../analyze.ticker";
|
import StockDetail from "../analyze.ticker";
|
||||||
|
import { MemoryRouter } from "react-router";
|
||||||
|
|
||||||
vi.mock("react-router", async () => {
|
vi.mock("react-router", async () => {
|
||||||
const actual = await vi.importActual("react-router");
|
const actual = await vi.importActual("react-router");
|
||||||
@@ -35,7 +36,7 @@ describe("StockDetail UI - executionPlan", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("displays executionPlan when sell decision returned", async () => {
|
it("displays executionPlan when sell decision returned", async () => {
|
||||||
render(<StockDetail />);
|
render(<MemoryRouter><StockDetail /></MemoryRouter>);
|
||||||
|
|
||||||
const runButton = screen.getByRole("button", { name: /Run Trading Graph Analysis/i });
|
const runButton = screen.getByRole("button", { name: /Run Trading Graph Analysis/i });
|
||||||
fireEvent.click(runButton);
|
fireEvent.click(runButton);
|
||||||
|
|||||||
Reference in New Issue
Block a user