40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { ArtifactView } from "./ArtifactView";
|
|
|
|
vi.mock("./mermaid", () => ({
|
|
renderMermaid: vi.fn().mockResolvedValue('<svg data-testid="mm"></svg>'),
|
|
}));
|
|
|
|
test("sql artifact renders the SQL text", () => {
|
|
render(<ArtifactView artifact={{ kind: "sql", data: "SELECT 1" }} />);
|
|
expect(screen.getByText("SELECT 1")).toBeInTheDocument();
|
|
});
|
|
|
|
test("cte_plan renders an ordered list of names", () => {
|
|
render(<ArtifactView artifact={{ kind: "cte_plan", data: { names: ["a_cte", "b_cte"] } }} />);
|
|
expect(screen.getByText("a_cte")).toBeInTheDocument();
|
|
expect(screen.getByText("b_cte")).toBeInTheDocument();
|
|
});
|
|
|
|
test("question renders markdown headings", () => {
|
|
render(<ArtifactView artifact={{ kind: "question", data: "## Domanda\nrevised" }} />);
|
|
expect(screen.getByText("Domanda")).toBeInTheDocument();
|
|
});
|
|
|
|
test("unknown kind falls back to formatted JSON", () => {
|
|
render(<ArtifactView artifact={{ kind: "mystery", data: { a: 1 } }} />);
|
|
expect(screen.getByText(/"a": 1/)).toBeInTheDocument();
|
|
});
|
|
|
|
test("schema_linking renders the schema viewer", async () => {
|
|
render(
|
|
<ArtifactView
|
|
artifact={{
|
|
kind: "schema_linking",
|
|
data: { candidates: [{ kind: "table", name: "orders", decision: "promoted" }], joins: [] },
|
|
}}
|
|
/>,
|
|
);
|
|
expect(await screen.findByTestId("mm")).toBeInTheDocument();
|
|
});
|