mod_test.tsx
1 import "../happyDomSetup.ts"; 2 import { render, screen, waitFor } from "@testing-library/react"; 3 import { useAccount, useEnsName, useWalletClient } from "wagmi"; 4 import { expect } from "@std/expect"; 5 import { hardhat } from "wagmi/chains"; 6 import { createRouterWrapper } from "./mod.tsx"; 7 8 const TestComponent = () => { 9 const { status } = useAccount(); 10 const { data: wallet } = useWalletClient(); 11 const { data: ensName } = useEnsName({ 12 address: wallet?.account.address, 13 }); 14 return ( 15 <div> 16 <p>{status}</p> 17 <p>{wallet?.chain?.id}</p> 18 <p>{ensName}</p> 19 </div> 20 ); 21 }; 22 23 Deno.test("Test wallet client is configured correctly for test environment", { 24 sanitizeResources: false, 25 sanitizeOps: false, 26 }, async () => { 27 const { wrapper } = await createRouterWrapper(); 28 29 render(<TestComponent />, { wrapper }); 30 31 await waitFor(() => { 32 expect(screen.getByText("connected")).toBeTruthy(); 33 }); 34 await waitFor(() => { 35 expect(screen.getByText(hardhat.id)).toBeTruthy(); 36 }); 37 });