Files
CoaxysPanel/tests/unit/data-table.test.tsx
T
arsam 3694212c29 Import tests: tests/unit/data-table
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
2026-09-18 23:11:20 +03:30

33 lines
947 B
TypeScript

"use client";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it } from "vitest";
import type { ColumnDef } from "@tanstack/react-table";
import { DataTable } from "@/components/common/data-table";
type Row = { name: string; status: string };
const columns: ColumnDef<Row>[] = [
{ accessorKey: "name", header: "Name" },
{ accessorKey: "status", header: "Status" },
];
describe("DataTable", () => {
it("filters rows by search input", async () => {
render(
<DataTable
data={[
{ name: "Alpha", status: "healthy" },
{ name: "Beta", status: "warning" },
]}
columns={columns}
/>,
);
await userEvent.type(screen.getByPlaceholderText("Search"), "Beta");
expect(screen.getByText("Beta")).toBeInTheDocument();
expect(screen.queryByText("Alpha")).not.toBeInTheDocument();
});
});