import React from "react"; import { render, screen } from "@testing-library/react"; import TransitionView from "../TransitionView"; jest.mock("framer-motion", () => { const actual = jest.requireActual("framer-motion"); return { ...actual, AnimatePresence: ({ children }: { children: React.ReactNode }) => <>{children} }; }); describe("TransitionView", () => { const mockChildren = [
Step 1
,
Step 2
,
Step 3
]; it("should render first step", () => { render( {mockChildren} ); expect(screen.getByText("Step 1")).toBeInTheDocument(); }); it("should display the correct step based on activeStep prop", () => { const { rerender } = render( {mockChildren} ); expect(screen.getByText("Step 1")).toBeInTheDocument(); rerender( {mockChildren} ); expect(screen.getByText("Step 2")).toBeInTheDocument(); }); });