import { describe, it, expect, vi } from "vitest"; // Stub the tRPC context factory so useTRPC() can run outside a React render: // the real context.useTRPC() requires a mounted TRPCProvider. The stubbed // proxy lets us exercise the router-agnostic delegation (client.ts:useTRPC). vi.mock("@trpc/tanstack-react-query", () => ({ createTRPCContext: () => ({ TRPCProvider: () => null, useTRPC: () => ({ __proxy: "trpc-options-proxy" }), }), })); import { useTRPC, TRPCProvider } from "./client"; describe("core-trpc client exports", () => { it("exports useTRPC hook", () => { expect(useTRPC).toBeTypeOf("function"); }); it("exports TRPCProvider component", () => { expect(TRPCProvider).toBeTypeOf("function"); }); it("useTRPC delegates to the underlying router-agnostic tRPC proxy", () => { // The generic is a compile-time-only cast; at runtime it returns whatever // the shared context proxy yields. expect(useTRPC()).toEqual({ __proxy: "trpc-options-proxy" }); }); });