import React, { useMemo } from "react"; import { render, screen } from "@testing-library/react"; import { createMemoryHistory } from "@nano-router/history"; import "@testing-library/jest-dom"; import { Routes, Route, Router, useRouter } from "./index.js"; const routes = new Routes(new Route("posts", "/posts")); const Location = () => { const router = useRouter(); return
{router.location.pathname}
; }; const App = () => { const history = useMemo( () => createMemoryHistory({ initialEntries: ["/posts"] }), [], ); return (
); }; describe("useRouter", () => { it("returns the router from the context", () => { render(); expect(screen.getByTestId("location")).toHaveTextContent("/posts"); }); });