24 lines
867 B
TypeScript
24 lines
867 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { SportIcon } from "~/components/SportIcon";
|
|
|
|
describe("SportIcon", () => {
|
|
it("renders a resolved legacy icon URL", () => {
|
|
render(<SportIcon sportName="NFL" iconUrl="nfl.svg" />);
|
|
|
|
const icon = screen.getByRole("img", { name: "NFL" });
|
|
expect(icon).toHaveAttribute("src", "/sports-icons/nfl.svg");
|
|
});
|
|
|
|
it("renders decorative icons with empty alt text", () => {
|
|
const { container } = render(<SportIcon sportName="NBA" iconUrl="https://example.com/nba.svg" decorative />);
|
|
|
|
expect(container.querySelector("img")).toHaveAttribute("alt", "");
|
|
});
|
|
|
|
it("falls back to a trophy when no icon URL exists", () => {
|
|
render(<SportIcon sportName="Golf" />);
|
|
|
|
expect(screen.getByLabelText("Golf")).toBeInTheDocument();
|
|
});
|
|
});
|