import { render, screen } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { Logo } from "./Logo"; describe("Logo", () => { it("renders an image with alt text", () => { render(); const img = screen.getByAltText("Jenado Unlimited"); expect(img).toBeInTheDocument(); }); it("wraps in a link by default", () => { render(); const link = screen.getByRole("link", { name: "Jenado Unlimited" }); expect(link).toHaveAttribute("href", "/"); }); it("does not wrap in a link when link=false", () => { render(); // There should be no link wrapping the logo const links = screen.queryAllByRole("link"); // Filter to those that would contain our logo image const logoLinks = links.filter( (l) => l.getAttribute("aria-label") === "Jenado Unlimited", ); expect(logoLinks.length).toBe(0); }); it("shows text when withText is true", () => { render(); expect(screen.getByText("Jenado Unlimited")).toBeInTheDocument(); }); });