import { afterEach, describe, expect, it, vi } from "vitest"; import { cleanup, render, screen } from "@testing-library/react"; import { PageHeader } from "./page-header"; import { NavigationButton } from "./navigation-button"; import { I18nProvider } from "@/translations/provider"; afterEach(() => { cleanup(); }); vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn(), replace: vi.fn(), back: vi.fn(), }), })); vi.mock("@/hooks/marriage/use-profile-main", () => ({ useMarriageProfileQuery: () => ({ data: undefined, isLoading: false, isFetched: true, }), })); function renderWithI18n(ui: React.ReactNode) { return render( {ui} ); } describe("PageHeader & NavigationButton Subscription Gender Restriction", () => { it("renders subscription button for male profile", () => { const maleProfile = { id: 101, gender: "male", status: "waiting", }; const { queryByRole } = renderWithI18n(); const subButton = queryByRole("button", { name: /وضعیت اشتراک|اشتراک|subscription/i, }); expect(subButton).toBeInTheDocument(); }); it("does NOT render subscription button for female profile", () => { const femaleProfile = { id: 243, gender: "female", status: "waiting", }; const { queryByRole } = renderWithI18n(); const subButton = queryByRole("button", { name: /وضعیت اشتراک|اشتراک|subscription/i, }); expect(subButton).not.toBeInTheDocument(); }); it("NavigationButton icon='subscription' returns null for female user", () => { const femaleProfile = { id: 243, gender: "female", }; const { container } = renderWithI18n( , ); expect(container).toBeEmptyDOMElement(); }); it("NavigationButton icon='subscription' renders button for male user", () => { const maleProfile = { id: 101, gender: "male", }; const { getByRole } = renderWithI18n( , ); const subButton = getByRole("button"); expect(subButton).toBeInTheDocument(); }); });