import React from "react" import { describe, expect, it, vi } from "vitest" import { render } from "@testing-library/react" import { MemoryRouter } from "react-router-dom" vi.mock("@/components/layout/PageHead", () => ({ default: ({ title }: { title: string }) =>
{title}
, })) vi.mock("@tanstack/react-query", () => ({ useQuery: () => ({ data: { plan: "free", status: "active", auto_renew: true }, isLoading: false, isError: false, refetch: vi.fn(), }), useMutation: () => ({ mutate: vi.fn(), mutateAsync: vi.fn(), isLoading: false, }), })) vi.mock("@/components/ui", () => ({ Button: ({ children, onClick }: any) => , Modal: ({ open, children }: any) => (open ?
{children}
: null), })) vi.mock("antd", () => ({ message: { success: vi.fn(), error: vi.fn(), warning: vi.fn() }, })) vi.mock("@/api/subscription", () => ({ getCurrentSubscription: vi.fn().mockResolvedValue({ plan: "free", status: "active" }), changePlan: vi.fn().mockResolvedValue({ success: true }), toggleAutoRenew: vi.fn().mockResolvedValue({ success: true }), cancelSubscription: vi.fn().mockResolvedValue({ success: true }), })) vi.mock("@/pages/subscription/UpgradeSubscription.css", () => ({})) import UpgradeSubscription from "@/pages/subscription/UpgradeSubscription" describe("UpgradeSubscription Page", () => { it("should render without crashing", () => { const { container } = render( , ) expect(container.querySelector(".xx-upgrade-page")).toBeTruthy() }) })