import { render, screen } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { Table } from "."; import { TableProps, LoadingProps } from "./Table.types"; const TestTable = (props: TableProps & LoadingProps) => { return ( Column 1 Column 2 Row 1, Cell 1 Row 1, Cell 2 Row 2, Cell 1 Row 2, Cell 2
); }; describe("Table", () => { describe("Snapshots", () => { it("should match the snapshot", () => { const res = render(); expect(res).toMatchSnapshot(); }); it("Should match the snapshot when searchable", () => { const res = render( ); expect(res).toMatchSnapshot(); }); it("should match the snapshot when in a loading state", () => { const res = render(); expect(res).toMatchSnapshot(); }); }); it("should renderEmpty when there is no rows", () => { render( Column 1 Column 2 "No data"}> {() => ( Cell 1 Cell 2 )}
); expect(screen.getByText("No data")).toBeTruthy(); }); });