| 123456789101112131415161718192021222324252627282930313233 |
- 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(<Logo />);
- const img = screen.getByAltText("Jenado Unlimited");
- expect(img).toBeInTheDocument();
- });
- it("wraps in a link by default", () => {
- render(<Logo />);
- const link = screen.getByRole("link", { name: "Jenado Unlimited" });
- expect(link).toHaveAttribute("href", "/");
- });
- it("does not wrap in a link when link=false", () => {
- render(<Logo link={false} />);
- // 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(<Logo withText />);
- expect(screen.getByText("Jenado Unlimited")).toBeInTheDocument();
- });
- });
|