Files
MattrixwvReactComponents/test/component/pill/SuccessPill.test.tsx
2026-02-26 23:10:08 -05:00

85 lines
3.2 KiB
TypeScript

import SuccessPill from "$/component/pill/SuccessPill";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
const textContent = "Testing";
describe("Renders", () => {
it("Renders with defaults", () => {
render(<SuccessPill>{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
expect(pillDiv).toHaveClass("rounded-full");
});
});
describe("Rounding", () => {
it("Renders with no rounding", () => {
render(<SuccessPill rounding="none">{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
});
it("Renders with small rounding", () => {
render(<SuccessPill rounding="sm">{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
expect(pillDiv).toHaveClass("rounded-sm");
});
it("Renders with medium rounding", () => {
render(<SuccessPill rounding="md">{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
expect(pillDiv).toHaveClass("rounded");
});
it("Renders with large rounding", () => {
render(<SuccessPill rounding="lg">{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
expect(pillDiv).toHaveClass("rounded-lg");
});
it("Renders with full rounding", () => {
render(<SuccessPill rounding="full">{textContent}</SuccessPill>);
//Make sure the pill div is present
const pillDiv = screen.getByTestId("mattrixwv-success-pill");
expect(pillDiv).toBeInTheDocument();
expect(pillDiv).toHaveTextContent(textContent);
//Check for the default classes
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
expect(pillDiv).toHaveClass("bg-success", "text-black");
expect(pillDiv).toHaveClass("rounded-full");
});
});