prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey

tests work with mocked nuqs

Tyler f443d318 b50fda4c

+13 -3
+13 -3
packages/site/tests/components/Playground.test.tsx
··· 1 1 import { describe, it, expect, vi } from "vitest"; 2 2 import { render, screen, waitFor } from "@testing-library/react"; 3 3 import { Playground } from "../../src/components/Playground"; 4 + import { NuqsTestingAdapter } from "nuqs/adapters/testing"; 4 5 5 6 vi.mock("@monaco-editor/react", () => ({ 6 7 default: ({ value, onChange }: any) => ( ··· 60 61 }, 61 62 })); 62 63 64 + // Helper function to render Playground with NuqsTestingAdapter 65 + function renderPlayground() { 66 + return render(<Playground />, { 67 + wrapper: ({ children }) => ( 68 + <NuqsTestingAdapter searchParams="">{children}</NuqsTestingAdapter> 69 + ), 70 + }); 71 + } 72 + 63 73 describe("Playground", () => { 64 74 it("renders Editor and OutputPanel components", async () => { 65 - render(<Playground />); 75 + renderPlayground(); 66 76 67 77 expect(screen.getByText("Input")).toBeInTheDocument(); 68 78 expect(screen.getByText("Output")).toBeInTheDocument(); ··· 74 84 }); 75 85 76 86 it("starts with default code in editor", async () => { 77 - render(<Playground />); 87 + renderPlayground(); 78 88 79 89 // Wait for editors to be ready 80 90 await waitFor(() => { ··· 88 98 }); 89 99 90 100 it("evaluates code and displays output", async () => { 91 - render(<Playground />); 101 + renderPlayground(); 92 102 93 103 await waitFor( 94 104 () => {