Add pill component
This commit is contained in:
78
test/component/pill/Pill.test.tsx
Normal file
78
test/component/pill/Pill.test.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import Pill from "$/component/pill/Pill";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
|
||||
const textContent = "Testing";
|
||||
|
||||
|
||||
describe("Renders", () => {
|
||||
it("Renders with defaults", () => {
|
||||
render(<Pill>{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-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("rounded-full");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Rounding", () => {
|
||||
it("Renders with no rounding", () => {
|
||||
render(<Pill rounding="none">{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-pill");
|
||||
expect(pillDiv).toBeInTheDocument();
|
||||
expect(pillDiv).toHaveTextContent(textContent);
|
||||
//Check for the default classes
|
||||
expect(pillDiv).toHaveClass("px-2", "text-sm", "whitespace-nowrap");
|
||||
});
|
||||
it("Renders with small rounding", () => {
|
||||
render(<Pill rounding="sm">{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-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("rounded-sm");
|
||||
});
|
||||
it("Renders with medium rounding", () => {
|
||||
render(<Pill rounding="md">{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-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("rounded");
|
||||
});
|
||||
it("Renders with large rounding", () => {
|
||||
render(<Pill rounding="lg">{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-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("rounded-lg");
|
||||
});
|
||||
it("Renders with full rounding", () => {
|
||||
render(<Pill rounding="full">{textContent}</Pill>);
|
||||
|
||||
//Make sure the pill div is present
|
||||
const pillDiv = screen.getByTestId("mattrixwv-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("rounded-full");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user