content-explorer/ui/components/ResultsTable.test.tsx
tegwick a6e360aaa5 Port the explorer shell: tokens, header, hero, and a generic table.
CONTENT-WP-0002-T01 adapts the pinned OnCo visual system under ui/ without the corpus, mark, or kind routes.

Assistant: grok
Assistant-Session: 01a1346c-fdff-7741-b1af-b7283661554b
2026-10-13 22:51:00 +02:00

36 lines
1.2 KiB
TypeScript

import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { ResultsTable } from "./ResultsTable";
type Row = { title: string; kindLabel: string };
const columns = [
{ key: "title", label: "Title", sortable: true, render: (row: Row) => row.title },
{ key: "kindLabel", label: "Kind", sortable: true, render: (row: Row) => row.kindLabel },
];
describe("ResultsTable", () => {
it("renders an empty state", () => {
const html = renderToStaticMarkup(
<ResultsTable columns={columns} rows={[]} rowKey={() => "none"} onSort={() => undefined} />,
);
expect(html).toContain("No records.");
expect(html).not.toContain("aria-sort");
});
it("exposes sort buttons and aria-sort for the active column", () => {
const html = renderToStaticMarkup(
<ResultsTable
columns={columns}
rows={[{ title: "Feedback", kindLabel: "Concept" } satisfies Row]}
rowKey={(row) => row.title}
sort={{ key: "title", dir: 1 }}
onSort={() => undefined}
/>,
);
expect(html).toContain("Sort by Kind");
expect(html).toContain('aria-sort="ascending"');
expect(html).toContain("Feedback");
expect(html).toContain(">Title");
});
});