import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, beforeEach, it, expect, vi } from "vitest";
import { ScoreValue } from "./index";
const useLocalContentMock = vi.fn(() => ({
    hideScoresList: [],
}));
vi.mock("~/sdks/LocalContent/context", () => ({
    useLocalContent: () => useLocalContentMock(),
}));
describe("ScoreValue", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders the score when value is between 1 and 10", () => {
        render(React.createElement(ScoreValue, { value: 7, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-value")).toHaveTextContent("7 / 10");
    });
    it("does not render when value is undefined", () => {
        const { container } = render(React.createElement(ScoreValue, { scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("does not render when scoreKey is undefined", () => {
        const { container } = render(React.createElement(ScoreValue, { scoreKey: undefined }));
        expect(container.firstChild).toBeNull();
    });
    it("does not render when scoreKey is in the hideScoresList list", () => {
        useLocalContentMock.mockReturnValue({
            hideScoresList: ["pedestrian_friendly"],
        });
        const { container } = render(React.createElement(ScoreValue, { value: 5, scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("does not render when value is 0", () => {
        const { container } = render(React.createElement(ScoreValue, { value: 0, scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("does not render when value is negative", () => {
        const { container } = render(React.createElement(ScoreValue, { value: -3, scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("does not render when value is not a number", () => {
        const { container } = render(
        // @ts-expect-error testing invalid prop
        React.createElement(ScoreValue, { value: "abc", scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("renders the minimum valid value", () => {
        render(React.createElement(ScoreValue, { value: 1, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-value")).toHaveTextContent("1 / 10");
    });
    it("renders the maximum valid value", () => {
        render(React.createElement(ScoreValue, { value: 10, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-value")).toHaveTextContent("10 / 10");
    });
    it("caps the score at 10", () => {
        render(React.createElement(ScoreValue, { value: 15, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-value")).toHaveTextContent("10 / 10");
    });
});
//# sourceMappingURL=index.test.js.map