import React from "react";
import { render, screen, cleanup } from "@testing-library/react";
import { describe, expect, it, afterEach } from "vitest";
// Component
import SkeletonOnTableLayout from "./SkeletonOnTableLayout";
describe("SkeletonOnTableLayout Component", () => {
afterEach(() => {
cleanup();
});
it("render component with default props", () => {
render();
const skeleton = screen.getAllByText("Loading content");
expect(skeleton.length).toBe(2);
});
it("renders with correct number of skeleton rows", () => {
render();
const rows = screen.getAllByRole("row");
expect(rows).toHaveLength(5);
});
it("renders with accessible text", () => {
render();
const strText = screen.getAllByText("Loading content");
// Check if the skeleton text is present in the document
strText.forEach((text) => {
expect(text).toBeInTheDocument();
});
});
it("renders with custom accessible text", () => {
const customText = "Loading data...";
render(
);
const strText = screen.getAllByText(customText);
// Check if the skeleton text is present in the document
strText.forEach((text) => {
expect(text).toBeInTheDocument();
});
});
it("renders with custom colspan", () => {
render();
const td = screen.getByRole("cell");
expect(td).toHaveAttribute("colspan", "5");
});
});