/* eslint-disable @typescript-eslint/no-explicit-any */
import React from "react";
import { render } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { SchoolAttributes } from ".";
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: (key) => key,
    }),
}));
describe("SchoolAttributes", () => {
    it("returns null when attributes are undefined", () => {
        const { container } = render(React.createElement(SchoolAttributes, { attributes: undefined }));
        expect(container.firstChild).toBeNull();
    });
    it("returns null when attributes are empty", () => {
        const { container } = render(React.createElement(SchoolAttributes, { attributes: {}, boardAttributes: undefined }));
        expect(container.firstChild).toBeNull();
    });
    it("renders school attributes correctly", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const { getByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: undefined }));
        const grades = getByTestId("school-attributes-grades");
        const programs = getByTestId("school-attributes-programs");
        const languages = getByTestId("school-attributes-languages");
        const types = getByTestId("school-attributes-types");
        expect(grades).toBeInTheDocument();
        expect(programs).toBeInTheDocument();
        expect(languages).toBeInTheDocument();
        expect(types).toBeInTheDocument();
        expect(grades).toHaveTextContent("common:map.marker.schoolAttributes.levels");
        expect(programs).toHaveTextContent("common:map.marker.schoolAttributes.programs");
        expect(languages).toHaveTextContent("common:map.marker.schoolAttributes.languages");
        expect(types).toHaveTextContent("common:map.marker.schoolAttributes.types");
    });
    it("renders board attributes when provided", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const boardAttributes = {
            url: "https://example.com/board",
        };
        const { getByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: boardAttributes }));
        const boardLink = getByTestId("school-attributes-board-link");
        expect(boardLink).toBeInTheDocument();
        expect(boardLink).toHaveAttribute("href", boardAttributes.url);
    });
    it("renders board attributes with correct label", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const boardAttributes = {
            url: "https://example.com/board",
        };
        const { getByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: boardAttributes }));
        const boardLabel = getByTestId("school-attributes-board");
        expect(boardLabel).toBeInTheDocument();
        expect(boardLabel).toHaveTextContent("common:map.marker.schoolAttributes.board");
    });
    it("does not render board attributes when not provided", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const { queryByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: undefined }));
        const boardLink = queryByTestId("school-attributes-board-link");
        expect(boardLink).not.toBeInTheDocument();
    });
    it("calls onLinkClick when board link is clicked", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const boardAttributes = {
            url: "https://example.com/board",
        };
        const onLinkClick = vi.fn();
        const { getByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: boardAttributes, onLinkClick: onLinkClick }));
        const boardLink = getByTestId("school-attributes-board-link");
        boardLink.click();
        expect(onLinkClick).toHaveBeenCalledWith(boardAttributes.url);
    });
    it("renders categories when provided", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const categories = ["advancedPlacement", "charter"];
        const { getByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: undefined, categories: categories }));
        const categoryElement = getByTestId("school-attributes-categories");
        expect(categoryElement).toBeInTheDocument();
        expect(categoryElement).toHaveTextContent("common:map.marker.schoolAttributes.categories");
        expect(categoryElement).toHaveTextContent("common:map.marker.categories.advancedPlacement");
        expect(categoryElement).toHaveTextContent("common:map.marker.categories.charter");
    });
    it("doesn't render categories when not provided", () => {
        const attributes = {
            grades: "K-12",
            programs: ["STEM", "Arts"],
            languages: ["English", "French"],
            types: ["Public", "Charter"],
        };
        const boardAttributes = {
            url: "https://example.com/board",
        };
        const { queryByTestId } = render(React.createElement(SchoolAttributes, { attributes: attributes, boardAttributes: boardAttributes }));
        const categoryElement = queryByTestId("school-attributes-categories");
        expect(categoryElement).not.toBeInTheDocument();
    });
});
//# sourceMappingURL=index.test.js.map