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, useLocation, Navigate } from "./index.js"; const routes = new Routes( new Route("posts", "/posts"), new Route("new", "/new"), ); const Location = () => { const location = useLocation(); return
{location.pathname}
; }; const App = () => { const history = useMemo( () => createMemoryHistory({ initialEntries: ["/posts"] }), [], ); return (
); }; describe("Navigate", () => { beforeEach(() => { render(); }); it("navigates to new route", () => { expect(screen.getByTestId("location")).toHaveTextContent("/new"); }); });