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, useQueryParams } from "./index.js"; const routes = new Routes(new Route("posts/edit", "/posts/:id")); const RouteQueryParams = () => { const { message } = useQueryParams(); return
{message}
; }; const App = () => { const history = useMemo( () => createMemoryHistory({ initialEntries: ["/posts/42?message=hello"] }), [], ); return (
); }; describe("useQueryParams", () => { it("returns route query params", () => { render(); expect(screen.getByTestId("query-params-message")).toHaveTextContent( "hello", ); }); });