diff --git a/lib/component/button/Button.tsx b/lib/component/button/Button.tsx index 06cb2b1..7ea8089 100644 --- a/lib/component/button/Button.tsx +++ b/lib/component/button/Button.tsx @@ -16,6 +16,7 @@ export default function Button(props: ButtonProps){ return ( ); + + const button = screen.getByTestId("mattrixwv-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + }); + it("Renders with custom className", () => { + const customClass = "custom-button-class"; + + render(); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label", () => { + const ariaLabel = "Custom Aria Label"; + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + describe("Button Rounding Variants", () => { + it("Renders with small rounding", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + describe("Button Size and Shape Variants", () => { + it("Renders with xs square", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); + describe("Button Variant Types", () => { + it("Renders with standard variant", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("border"); + }); + it("Renders with outline variant", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("border"); + }); + it("Renders with outline-ghost variant", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("border"); + }); + it("Renders with ghost variant", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("border-none"); + }); + it("Renders with icon variant", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("border-none"); + }); + }); +}); + +describe("Button Component Disabled", () => { + it("Render with defaults", () => { + render(); + + const button = screen.getByTestId("mattrixwv-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).not.toHaveClass("cursor-pointer"); + }); + it("Renders with custom className", () => { + const customClass = "custom-button-class"; + + render(); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label", () => { + const ariaLabel = "Custom Aria Label"; + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick when disabled", async () => { + const handleClick = vi.fn(); + + render(); + + const button = screen.getByTestId("mattrixwv-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).not.toHaveBeenCalled(); + }); +}); diff --git a/test/component/button/DangerButton.test.tsx b/test/component/button/DangerButton.test.tsx new file mode 100644 index 0000000..0eed932 --- /dev/null +++ b/test/component/button/DangerButton.test.tsx @@ -0,0 +1,306 @@ +import DangerButton from "$/component/button/DangerButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Danger Button"; + + +describe("DangerButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-red-600", "hover:bg-red-700", "active:bg-red-800"); + expect(button).toHaveClass("border-red-600", "hover:border-red-700", "active:border-red-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className", () => { + const customClass = "custom-danger-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label", () => { + const ariaLabel = "Danger Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + describe("DangerButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + describe("DangerButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("DangerButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-red-400/80"); + expect(button).toHaveClass("border-red-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-danger-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Danger Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("DangerButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-red-600", "hover:bg-red-700", "active:bg-red-800"); + expect(button).toHaveClass("border", "border-red-600", "hover:border-red-700", "active:border-red-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-red-600", "hover:border-red-700", "active:border-red-800"); + expect(button).toHaveClass("text-red-600", "hover:text-red-700", "active:text-red-800"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-red-600", "active:bg-red-700"); + expect(button).toHaveClass("border", "border-red-600", "hover:border-red-600", "active:border-red-700"); + expect(button).toHaveClass("text-red-600", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-red-600", "active:bg-red-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-red-600", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-red-600", "hover:text-red-700", "active:text-red-800"); + }); +}); + +describe("DangerButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-red-400/80"); + expect(button).toHaveClass("border", "border-red-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-red-400/80"); + expect(button).toHaveClass("text-red-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-red-400/80"); + expect(button).toHaveClass("text-red-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-red-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-danger-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-red-400/80"); + }); +}); diff --git a/test/component/button/DarkButton.test.tsx b/test/component/button/DarkButton.test.tsx new file mode 100644 index 0000000..039fc53 --- /dev/null +++ b/test/component/button/DarkButton.test.tsx @@ -0,0 +1,311 @@ +import DarkButton from "$/component/button/DarkButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Dark Button"; + + +describe("DarkButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-black", "hover:bg-neutral-700", "active:bg-neutral-600"); + expect(button).toHaveClass("border-black", "hover:border-neutral-700", "active:border-neutral-600"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-dark-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Dark Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("DarkButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("DarkButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("DarkButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-neutral-700/80"); + expect(button).toHaveClass("border-neutral-700/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-dark-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Dark Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("DarkButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-black", "hover:bg-neutral-700", "active:bg-neutral-600"); + expect(button).toHaveClass("border", "border-black", "hover:border-neutral-700", "active:border-neutral-600"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-black", "hover:border-neutral-700", "active:border-neutral-600"); + expect(button).toHaveClass("text-black", "hover:text-neutral-700", "active:text-neutral-600"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-black", "active:bg-neutral-700"); + expect(button).toHaveClass("border", "border-black", "hover:border-black", "active:border-neutral-700"); + expect(button).toHaveClass("text-black", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-black", "active:bg-neutral-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-black", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-black", "hover:text-neutral-700", "active:text-neutral-600"); + }); +}); + +describe("DarkButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-neutral-700/80"); + expect(button).toHaveClass("border", "border-neutral-700/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-700/80"); + expect(button).toHaveClass("text-neutral-700/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-700/80"); + expect(button).toHaveClass("text-neutral-700/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-700/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-dark-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-700/80"); + }); +}); diff --git a/test/component/button/InfoButton.test.tsx b/test/component/button/InfoButton.test.tsx new file mode 100644 index 0000000..55a6528 --- /dev/null +++ b/test/component/button/InfoButton.test.tsx @@ -0,0 +1,311 @@ +import InfoButton from "$/component/button/InfoButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Info Button"; + + +describe("InfoButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-cyan-500", "hover:bg-cyan-600", "active:bg-cyan-700"); + expect(button).toHaveClass("border-cyan-500", "hover:border-cyan-600", "active:border-cyan-700"); + expect(button).toHaveClass("text-black"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-info-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Info Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("InfoButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("InfoButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("InfoButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-sky-300/80"); + expect(button).toHaveClass("border-sky-300/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-info-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Info Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("InfoButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-cyan-500", "hover:bg-cyan-600", "active:bg-cyan-700"); + expect(button).toHaveClass("border", "border-cyan-500", "hover:border-cyan-600", "active:border-cyan-700"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-cyan-500", "hover:border-cyan-600", "active:border-cyan-700"); + expect(button).toHaveClass("text-cyan-500", "hover:text-cyan-600", "active:text-cyan-700"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-cyan-500", "active:bg-cyan-600"); + expect(button).toHaveClass("border", "border-cyan-500", "hover:border-cyan-500", "active:border-cyan-600"); + expect(button).toHaveClass("text-cyan-500", "hover:text-black", "active:text-black"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-cyan-500", "active:bg-cyan-600"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-cyan-500", "hover:text-black", "active:text-black"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-cyan-500", "hover:text-cyan-600", "active:text-cyan-700"); + }); +}); + +describe("InfoButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-sky-300/80"); + expect(button).toHaveClass("border", "border-sky-300/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-sky-300/80"); + expect(button).toHaveClass("text-sky-300/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-sky-300/80"); + expect(button).toHaveClass("text-sky-300/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-sky-300/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-info-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-sky-300/80"); + }); +}); diff --git a/test/component/button/LightButton.test.tsx b/test/component/button/LightButton.test.tsx new file mode 100644 index 0000000..07b885c --- /dev/null +++ b/test/component/button/LightButton.test.tsx @@ -0,0 +1,311 @@ +import LightButton from "$/component/button/LightButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Light Button"; + + +describe("LightButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-white", "hover:bg-neutral-300", "active:bg-neutral-400"); + expect(button).toHaveClass("border-white", "hover:border-neutral-300", "active:border-neutral-400"); + expect(button).toHaveClass("text-black"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-light-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Light Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("LightButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("LightButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("LightButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-neutral-400/80"); + expect(button).toHaveClass("border-neutral-400/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-light-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Light Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("LightButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-white", "hover:bg-neutral-300", "active:bg-neutral-400"); + expect(button).toHaveClass("border", "border-white", "hover:border-neutral-300", "active:border-neutral-400"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-white", "hover:border-neutral-300", "active:border-neutral-400"); + expect(button).toHaveClass("text-white", "hover:text-neutral-300", "active:text-neutral-400"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-white", "active:bg-neutral-300"); + expect(button).toHaveClass("border", "border-white", "hover:border-white", "active:border-neutral-300"); + expect(button).toHaveClass("text-white", "hover:text-black", "active:text-black"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-white", "active:bg-neutral-300"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-white", "hover:text-black", "active:text-black"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-white", "hover:text-neutral-300", "active:text-neutral-400"); + }); +}); + +describe("LightButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-neutral-400/80"); + expect(button).toHaveClass("border", "border-neutral-400/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-400/80"); + expect(button).toHaveClass("text-neutral-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-400/80"); + expect(button).toHaveClass("text-neutral-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-light-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-400/80"); + }); +}); diff --git a/test/component/button/MoltenButton.test.tsx b/test/component/button/MoltenButton.test.tsx new file mode 100644 index 0000000..ac57710 --- /dev/null +++ b/test/component/button/MoltenButton.test.tsx @@ -0,0 +1,311 @@ +import MoltenButton from "$/component/button/MoltenButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Molten Button"; + + +describe("MoltenButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-orange-600", "hover:bg-orange-700", "active:bg-orange-800"); + expect(button).toHaveClass("border-orange-600", "hover:border-orange-700", "active:border-orange-800"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-molten-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Molten Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("MoltenButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("MoltenButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("MoltenButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-orange-400/80"); + expect(button).toHaveClass("border-orange-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-molten-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Molten Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("MoltenButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-orange-600", "hover:bg-orange-700", "active:bg-orange-800"); + expect(button).toHaveClass("border", "border-orange-600", "hover:border-orange-700", "active:border-orange-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-orange-600", "hover:border-orange-700", "active:border-orange-800"); + expect(button).toHaveClass("text-orange-600", "hover:text-orange-700", "active:text-orange-800"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-orange-600", "active:bg-orange-700"); + expect(button).toHaveClass("border", "border-orange-600", "hover:border-orange-600", "active:border-orange-700"); + expect(button).toHaveClass("text-orange-600", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-orange-600", "active:bg-orange-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-orange-600", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-orange-600", "hover:text-orange-700", "active:text-orange-800"); + }); +}); + +describe("MoltenButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-orange-400/80"); + expect(button).toHaveClass("border", "border-orange-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-orange-400/80"); + expect(button).toHaveClass("text-orange-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-orange-400/80"); + expect(button).toHaveClass("text-orange-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-orange-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-molten-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-orange-400/80"); + }); +}); diff --git a/test/component/button/PrimaryButton.test.tsx b/test/component/button/PrimaryButton.test.tsx new file mode 100644 index 0000000..ccf2127 --- /dev/null +++ b/test/component/button/PrimaryButton.test.tsx @@ -0,0 +1,311 @@ +import PrimaryButton from "$/component/button/PrimaryButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Primary Button"; + + +describe("PrimaryButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-blue-600", "hover:bg-blue-700", "active:bg-blue-800"); + expect(button).toHaveClass("border-blue-600", "hover:border-blue-700", "active:border-blue-800"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-primary-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Primary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("PrimaryButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("PrimaryButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("PrimaryButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-blue-400/80"); + expect(button).toHaveClass("border-blue-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-primary-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Primary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("PrimaryButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-blue-600", "hover:bg-blue-700", "active:bg-blue-800"); + expect(button).toHaveClass("border", "border-blue-600", "hover:border-blue-700", "active:border-blue-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-blue-600", "hover:border-blue-700", "active:border-blue-800"); + expect(button).toHaveClass("text-blue-600", "hover:text-blue-700", "active:text-blue-800"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-blue-600", "active:bg-blue-700"); + expect(button).toHaveClass("border", "border-blue-600", "hover:border-blue-600", "active:border-blue-700"); + expect(button).toHaveClass("text-blue-600", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-blue-600", "active:bg-blue-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-blue-600", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-blue-600", "hover:text-blue-700", "active:text-blue-800"); + }); +}); + +describe("PrimaryButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-blue-400/80"); + expect(button).toHaveClass("border", "border-blue-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-blue-400/80"); + expect(button).toHaveClass("text-blue-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-blue-400/80"); + expect(button).toHaveClass("text-blue-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-blue-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-primary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-blue-400/80"); + }); +}); diff --git a/test/component/button/SecondaryButton.test.tsx b/test/component/button/SecondaryButton.test.tsx new file mode 100644 index 0000000..fdb3882 --- /dev/null +++ b/test/component/button/SecondaryButton.test.tsx @@ -0,0 +1,309 @@ +import SecondaryButton from "$/component/button/SecondaryButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Secondary Button"; + + +describe("SecondaryButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-neutral-500", "hover:bg-neutral-600", "active:bg-neutral-700"); + expect(button).toHaveClass("border-neutral-500", "hover:border-neutral-600", "active:border-neutral-700"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-secondary-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Secondary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("SecondaryButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("SecondaryButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("SecondaryButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-neutral-300/80"); + expect(button).toHaveClass("border-neutral-300/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-secondary-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Secondary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("SecondaryButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-neutral-500", "hover:bg-neutral-600", "active:bg-neutral-700"); + expect(button).toHaveClass("border", "border-neutral-500", "hover:border-neutral-600", "active:border-neutral-700"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-500", "hover:border-neutral-600", "active:border-neutral-700"); + expect(button).toHaveClass("text-neutral-500", "hover:text-neutral-600", "active:text-neutral-700"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-neutral-500", "active:bg-neutral-600"); + expect(button).toHaveClass("border", "border-neutral-500", "hover:border-neutral-500", "active:border-neutral-600"); + expect(button).toHaveClass("text-neutral-500", "hover:text-black", "active:text-black"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-neutral-500", "active:bg-neutral-600"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-500", "hover:text-black", "active:text-black"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-500", "hover:text-neutral-600", "active:text-neutral-700"); + }); +}); + +describe("SecondaryButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-neutral-300/80"); + expect(button).toHaveClass("border", "border-neutral-300/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-300/80"); + expect(button).toHaveClass("text-neutral-300/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-neutral-300/80"); + expect(button).toHaveClass("text-neutral-300/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-300/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-secondary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-neutral-300/80"); + }); +}); diff --git a/test/component/button/SuccessButton.test.tsx b/test/component/button/SuccessButton.test.tsx new file mode 100644 index 0000000..3d0b305 --- /dev/null +++ b/test/component/button/SuccessButton.test.tsx @@ -0,0 +1,309 @@ +import SuccessButton from "$/component/button/SuccessButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Success Button"; + + +describe("SuccessButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-green-600", "hover:bg-green-700", "active:bg-green-800"); + expect(button).toHaveClass("border-green-600", "hover:border-green-700", "active:border-green-800"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-success-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Success Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("SuccessButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("SuccessButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("SuccessButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-green-400/80"); + expect(button).toHaveClass("border-green-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-success-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Success Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("SuccessButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-green-600", "hover:bg-green-700", "active:bg-green-800"); + expect(button).toHaveClass("border", "border-green-600", "hover:border-green-700", "active:border-green-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-green-600", "hover:border-green-700", "active:border-green-800"); + expect(button).toHaveClass("text-green-600", "hover:text-green-700", "active:text-green-800"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-green-600", "active:bg-green-700"); + expect(button).toHaveClass("border", "border-green-600", "hover:border-green-600", "active:border-green-700"); + expect(button).toHaveClass("text-green-600", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-green-600", "active:bg-green-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-green-600", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-green-600", "hover:text-green-700", "active:text-green-800"); + }); +}); + +describe("SuccessButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-green-400/80"); + expect(button).toHaveClass("border", "border-green-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-green-400/80"); + expect(button).toHaveClass("text-green-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-green-400/80"); + expect(button).toHaveClass("text-green-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-green-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-success-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-green-400/80"); + }); +}); diff --git a/test/component/button/TertiaryButton.test.tsx b/test/component/button/TertiaryButton.test.tsx new file mode 100644 index 0000000..2889eba --- /dev/null +++ b/test/component/button/TertiaryButton.test.tsx @@ -0,0 +1,309 @@ +import TertiaryButton from "$/component/button/TertiaryButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Tertiary Button"; + + +describe("TertiaryButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-purple-600", "hover:bg-purple-700", "active:bg-purple-800"); + expect(button).toHaveClass("border-purple-600", "hover:border-purple-700", "active:border-purple-800"); + expect(button).toHaveClass("text-white"); + }); + + it("Renders with custom className", () => { + const customClass = "custom-tertiary-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + + it("Renders with aria-label", () => { + const ariaLabel = "Tertiary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + describe("TertiaryButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + + describe("TertiaryButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("TertiaryButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-purple-400/80"); + expect(button).toHaveClass("border-purple-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-tertiary-button-class"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Tertiary Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("TertiaryButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-purple-600", "hover:bg-purple-700", "active:bg-purple-800"); + expect(button).toHaveClass("border", "border-purple-600", "hover:border-purple-700", "active:border-purple-800"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-purple-600", "hover:border-purple-700", "active:border-purple-800"); + expect(button).toHaveClass("text-purple-600", "hover:text-purple-700", "active:text-purple-800"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-purple-600", "active:bg-purple-700"); + expect(button).toHaveClass("border", "border-purple-600", "hover:border-purple-600", "active:border-purple-700"); + expect(button).toHaveClass("text-purple-600", "hover:text-white", "active:text-white"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-purple-600", "active:bg-purple-700"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-purple-600", "hover:text-white", "active:text-white"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-purple-600", "hover:text-purple-700", "active:text-purple-800"); + }); +}); + +describe("TertiaryButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-purple-400/80"); + expect(button).toHaveClass("border", "border-purple-400/80"); + expect(button).toHaveClass("text-white"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-purple-400/80"); + expect(button).toHaveClass("text-purple-400/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-purple-400/80"); + expect(button).toHaveClass("text-purple-400/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-purple-400/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-tertiary-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-purple-400/80"); + }); +}); diff --git a/test/component/button/WarningButton.test.tsx b/test/component/button/WarningButton.test.tsx new file mode 100644 index 0000000..499868d --- /dev/null +++ b/test/component/button/WarningButton.test.tsx @@ -0,0 +1,306 @@ +import WarningButton from "$/component/button/WarningButton"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, expect, it, vi } from "vitest"; + + +const buttonText = "Warning Button"; + + +describe("WarningButton Component", () => { + it("Renders with defaults", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + expect(button).toHaveClass("cursor-pointer"); + //Colors + expect(button).toHaveClass("bg-yellow-500", "hover:bg-yellow-600", "active:bg-yellow-700"); + expect(button).toHaveClass("border-yellow-500", "hover:border-yellow-600", "active:border-yellow-700"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with custom className", () => { + const customClass = "custom-danger-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label", () => { + const ariaLabel = "Danger Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Renders with onClick handler", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + describe("WarningButton Component Rounding", () => { + it("Renders with small rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-sm"); + }); + it("Renders with medium rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-md"); + }); + it("Renders with large rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-lg"); + }); + it("Renders with full rounding", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("rounded-full"); + }); + }); + describe("WarningButton Component Size and Shape", () => { + it("Renders with xs square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-0"); + }); + it("Renders with sm square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-1"); + }); + it("Renders with md square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-2"); + }); + it("Renders with lg square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-3"); + }); + it("Renders with xl square", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("p-4"); + }); + it("Renders with xs rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-1", "py-0"); + }); + it("Renders with sm rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-2", "py-1"); + }); + it("Renders with md rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-4", "py-2"); + }); + it("Renders with lg rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-6", "py-3"); + }); + it("Renders with xl rectangle", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("px-8", "py-4"); + }); + }); +}); + +describe("WarningButton Component Disabled", () => { + it("Render with defaults when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + //Check button requirements + expect(button).toBeInTheDocument(); + expect(button).toHaveTextContent(buttonText); + //Classes + expect(button).toHaveClass("rounded-lg"); + expect(button).toHaveClass("px-4", "py-2"); + expect(button).toHaveClass("border"); + //Disabled state + expect(button).not.toHaveClass("cursor-pointer"); + expect(button).toHaveClass("bg-yellow-300/80"); + expect(button).toHaveClass("border-yellow-300/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with custom className when disabled", () => { + const customClass = "custom-danger-button-class"; + + render({buttonText}); + + //Check button requirements + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass(customClass); + }); + it("Renders with aria-label when disabled", () => { + const ariaLabel = "Danger Button Aria Label"; + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-label", ariaLabel); + }); + it("Does not trigger onClick handler when disabled", async () => { + const handleClick = vi.fn(); + + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + + await userEvent.click(button); + expect(handleClick).toHaveBeenCalledTimes(0); + }); +}); + +describe("WarningButton Component Variants", () => { + it("Renders with standard variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-yellow-500", "hover:bg-yellow-600", "active:bg-yellow-700"); + expect(button).toHaveClass("border", "border-yellow-500", "hover:border-yellow-600", "active:border-yellow-700"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-yellow-500", "hover:border-yellow-600", "active:border-yellow-700"); + expect(button).toHaveClass("text-yellow-500", "hover:text-yellow-600", "active:text-yellow-700"); + }); + it("Renders with outline-ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-yellow-500", "active:bg-yellow-600"); + expect(button).toHaveClass("border", "border-yellow-500", "hover:border-yellow-500", "active:border-yellow-600"); + expect(button).toHaveClass("text-yellow-500", "hover:text-black", "active:text-black"); + }); + it("Renders with ghost variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent", "hover:bg-yellow-500", "active:bg-yellow-600"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-yellow-500", "hover:text-black", "active:text-black"); + }); + it("Renders with icon variant", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-yellow-500", "hover:text-yellow-600", "active:text-yellow-700"); + }); +}); + +describe("WarningButton Component Variants Disabled", () => { + it("Renders with standard variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-yellow-300/80"); + expect(button).toHaveClass("border", "border-yellow-300/80"); + expect(button).toHaveClass("text-black"); + }); + it("Renders with outline variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-yellow-300/80"); + expect(button).toHaveClass("text-yellow-300/80"); + }); + it("Renders with outline-ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border", "border-yellow-300/80"); + expect(button).toHaveClass("text-yellow-300/80"); + }); + it("Renders with ghost variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-yellow-300/80"); + }); + it("Renders with icon variant when disabled", () => { + render({buttonText}); + + const button = screen.getByTestId("mattrixwv-warning-button"); + expect(button).toBeInTheDocument(); + expect(button).toHaveClass("bg-transparent"); + expect(button).toHaveClass("border-none"); + expect(button).toHaveClass("text-yellow-300/80"); + }); +});