|
| 1 | +import { vi } from "vitest"; |
| 2 | +import { render, screen } from "@testing-library/react"; |
| 3 | +import { describe, it, expect } from "vitest"; |
| 4 | +import TutorialHelloWorld from "../page"; |
| 5 | + |
| 6 | +// Mock the BackToDashBoardLink component |
| 7 | +vi.mock("@/components/back-to-dashboard-link", () => ({ |
| 8 | + default: () => <div data-testid="back-to-dashboard-link">Back to Dashboard</div>, |
| 9 | +})); |
| 10 | + |
| 11 | +// Mock react-youtube |
| 12 | +vi.mock("react-youtube", () => ({ |
| 13 | + default: ({ videoId }: { videoId: string }) => ( |
| 14 | + <div data-testid="youtube-player" data-videoid={videoId}> |
| 15 | + YouTube Player |
| 16 | + </div> |
| 17 | + ), |
| 18 | +})); |
| 19 | + |
| 20 | +describe("Tutorial Hello World Page Tests", () => { |
| 21 | + it("should render the main quest heading", () => { |
| 22 | + render(<TutorialHelloWorld />); |
| 23 | + expect( |
| 24 | + screen.getByRole("heading", { name: /Quest: The Oracle's First Greeting/i }) |
| 25 | + ).toBeInTheDocument(); |
| 26 | + }); |
| 27 | + |
| 28 | + it("should render the back to dashboard link", () => { |
| 29 | + render(<TutorialHelloWorld />); |
| 30 | + expect(screen.getByTestId("back-to-dashboard-link")).toBeInTheDocument(); |
| 31 | + }); |
| 32 | + |
| 33 | + it("should render the YouTube video component", () => { |
| 34 | + render(<TutorialHelloWorld />); |
| 35 | + const youtubePlayer = screen.getByTestId("youtube-player"); |
| 36 | + expect(youtubePlayer).toBeInTheDocument(); |
| 37 | + expect(youtubePlayer).toHaveAttribute("data-videoid", "hp4pYFASTrc"); |
| 38 | + }); |
| 39 | +}); |
0 commit comments