import { describe, it, expect, vi } from "vitest"; import { render, screen, fireEvent } from "@testing-library/react"; import { MapStyleSwitcher } from "../../../src/features/map/MapStyleSwitcher"; import { MAP_STYLES } from "../../../src/features/map/types"; describe("MapStyleSwitcher", () => { it("renders one button per map style", () => { render( {}} />); for (const s of MAP_STYLES) { expect(screen.getByRole("button", { name: s.name })).toBeInTheDocument(); } }); it("marks the active style with aria-pressed=true and others false", () => { render( {}} />); expect(screen.getByRole("button", { name: "Liberty" })).toHaveAttribute("aria-pressed", "true"); expect(screen.getByRole("button", { name: "Dark" })).toHaveAttribute("aria-pressed", "false"); }); it("calls onChange with the style id when a button is clicked", () => { const onChange = vi.fn(); render(); fireEvent.click(screen.getByRole("button", { name: "Light" })); expect(onChange).toHaveBeenCalledWith("positron"); }); it("exposes the group with an accessible label", () => { render( {}} />); expect(screen.getByRole("group", { name: /map style/i })).toBeInTheDocument(); }); });