function assertEqual(actual: T, expected: T, message: string): void { if (actual !== expected) throw new Error(`${message}: expected ${String(expected)}, got ${String(actual)}`); } import { renderToStaticMarkup } from "react-dom/server"; import { DataGridEmptyAction, DataGridRowActions } from "../src/components/table/DataGrid"; function noop() {} function buttonCount(markup: string): number { return markup.match(/]*\btype="button"/g)?.length ?? 0; } const rowActions = renderToStaticMarkup(
); assertEqual(buttonCount(rowActions), 4, "row actions render the expected controls"); assertEqual(nonSubmittingButtonCount(rowActions), 4, "row actions do not submit an enclosing form"); const emptyAction = renderToStaticMarkup(
); assertEqual(buttonCount(emptyAction), 1, "empty action renders the expected control"); assertEqual(nonSubmittingButtonCount(emptyAction), 1, "empty action does not submit an enclosing form");