import React from "react"; import { render, screen } from "@testing-library/react"; import { describe, it, expect } from "vitest"; import Logo from "../../app/components/icons/Logo"; import { componentTestSuite, ComponentTestSuiteConfig, } from "../utils/componentTestSuite"; type LogoProps = React.ComponentProps; const baseProps: LogoProps = {}; const config: ComponentTestSuiteConfig = { component: Logo, name: "Logo", props: baseProps, primaryRole: "link", testCases: { renders: true, accessibility: true, keyboardNavigation: true, disabledState: false, errorState: false, }, }; componentTestSuite(config); describe("Logo (behavioral tests)", () => { it("renders as a link to home", () => { render(); const logo = screen.getByRole("link", { name: /communityrule logo/i }); expect(logo).toHaveAttribute("href", "/"); expect(logo).toHaveAttribute("aria-label", "CommunityRule Logo"); }); it("renders logo icon", () => { render(); expect(screen.getByAltText("CommunityRule Logo Icon")).toBeInTheDocument(); }); it("renders text by default", () => { render(); expect(screen.getByText("CommunityRule")).toBeInTheDocument(); }); it("hides text when showText is false", () => { const { container } = render(); const textElement = container.querySelector('.hidden'); expect(textElement).toBeInTheDocument(); expect(screen.getByAltText("CommunityRule Logo Icon")).toBeInTheDocument(); }); it("renders with different size variants", () => { const { rerender } = render(); expect(screen.getByRole("link")).toBeInTheDocument(); rerender(); expect(screen.getByRole("link")).toBeInTheDocument(); rerender(); expect(screen.getByRole("link")).toBeInTheDocument(); rerender(); expect(screen.getByRole("link")).toBeInTheDocument(); rerender(); expect(screen.getByRole("link")).toBeInTheDocument(); }); });