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