import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "@chopin/visuals"; import type { TableBodyProps, TableCellProps, TableFooterProps, TableHeaderProps, TableHeadProps, TableProps, TableRowProps, } from "@chopin/visuals"; import { expect, test } from "bun:test"; import { renderToStaticMarkup } from "react-dom/server"; test("exports the complete native presentation table API", () => { let table: TableProps = { variant: "contained" }; let header: TableHeaderProps = {}; let body: TableBodyProps = {}; let footer: TableFooterProps = {}; let row: TableRowProps = {}; let head: TableHeadProps = { scope: "col" }; let cell: TableCellProps = { headers: "status" }; expect([ Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, ].every(component => typeof component === "function")).toBe(true); expect(table.variant).toBe("contained"); expect([header, body, footer, row, head, cell]).toHaveLength(6); }); test( "renders native table elements with authoritative slots and forwarded semantic attributes", () => { let markup = renderToStaticMarkup( Environment Status Production Healthy 2 environments
, ); expect(markup.startsWith('
{ let plain = renderToStaticMarkup(); let contained = renderToStaticMarkup(
); expect(plain).toContain('data-slot="table"'); expect(plain).toContain('data-variant="plain"'); expect(contained).toContain('data-slot="table"'); expect(contained).toContain('data-variant="contained"'); }); test("uses the existing type and colour tokens in a horizontal overflow container", async () => { let css = await Bun.file(new URL("./table.css", import.meta.url)).text(); let styles = await Bun.file(new URL("../styles.css", import.meta.url)).text(); expect(styles).toContain('@import "./ui/table.css";'); expect(css).toContain("max-width: 100%;"); expect(css).toContain("overflow-x: auto;"); expect(css).toContain("width: 100%;"); expect(css).toContain("border-collapse: collapse;"); expect(css).toContain("font-size: var(--text-sm);"); expect(css).toContain("line-height: var(--text-sm--line-height);"); expect(css).toContain("color: var(--color-text-primary);"); expect(css).toContain("color: var(--color-text-secondary);"); expect(css).toContain("border-color: var(--color-edge);"); expect(css).not.toMatch(/#[\da-f]{3,8}|(?:oklch|rgb|hsl)\(/i); });