import type { FC } from 'react'; import { render, screen } from '@testing-library/react'; import { MemoryRouter as Router, Routes, Route, Navigate, RouterProvider, createMemoryRouter, } from 'react-router-dom'; import { useRecentlyVisited } from './useRecentlyVisited'; import { RecentlyVisitedRecorder } from 'component/commandBar/RecentlyVisitedRecorder'; const RouteNameRender: FC<{}> = () => { const { lastVisited } = useRecentlyVisited(); return (
{lastVisited.map((visited) => (
{visited.pathName}
))}
); }; beforeEach(() => { window.localStorage.clear(); }); test('checks that routes that exist in routes.ts gets added to lastVisited', async () => { render( } /> } /> } /> } /> } /> } /> } /> segment div} /> , ); await screen.findByText('/search'); await screen.findByText('/integrations'); await screen.findByText('/segments'); await screen.findByText('segment div'); }); test('visiting gets added to the list', async () => { const router = createMemoryRouter([ { path: '/search', element: }, { path: '/projects', element: }, { path: '/', element: }, ]); render(); router.navigate('/search'); await screen.findByText('/search'); router.navigate('/projects'); await screen.findByText('/projects'); });