import React from "react";
import { vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { Title } from "./index";
// Mock translations
const tMock = vi.fn();
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: tMock,
    }),
}));
describe("Title", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders the provided string title", () => {
        tMock.mockImplementation((key) => key);
        render(React.createElement(Title, { title: "Custom Title" }));
        const heading = screen.getByTestId("sidebar-header-title");
        expect(heading).toHaveTextContent("Custom Title");
        expect(heading).toHaveAttribute("aria-label", "Custom Title");
    });
    it("renders the translated title when title is undefined", () => {
        tMock.mockImplementation((key) => key);
        render(React.createElement(Title, null));
        const heading = screen.getByTestId("sidebar-header-title");
        expect(heading).toHaveTextContent("sidebar.header.title");
        expect(heading).toHaveAttribute("aria-label", "sidebar.header.title");
    });
    it("renders the translated title when title is true", () => {
        tMock.mockImplementation((key) => key);
        render(React.createElement(Title, { title: true }));
        const heading = screen.getByTestId("sidebar-header-title");
        expect(heading).toHaveTextContent("sidebar.header.title");
        expect(heading).toHaveAttribute("aria-label", "sidebar.header.title");
    });
    it("renders empty string when title is false", () => {
        tMock.mockImplementation((key) => key);
        render(React.createElement(Title, { title: false }));
        const heading = screen.getByTestId("sidebar-header-title");
        expect(heading).toBeEmptyDOMElement();
        expect(heading).toHaveAttribute("aria-label", "sidebar.header.title");
    });
    it("renders correctly with empty string as title", () => {
        tMock.mockImplementation((key) => key);
        render(React.createElement(Title, { title: "" }));
        const heading = screen.getByTestId("sidebar-header-title");
        expect(heading).toHaveTextContent("sidebar.header.title");
        expect(heading).toHaveAttribute("aria-label", "sidebar.header.title");
    });
});
//# sourceMappingURL=index.test.js.map