123456789101112131415161718192021222324252627282930313233343536 |
- import {createMemoryHistory, Route, Router, RouterContext} from 'react-router';
- import {render} from 'sentry-test/reactTestingLibrary';
- import {useNavigate} from 'sentry/utils/useNavigate';
- import {RouteContext} from 'sentry/views/routeContext';
- describe('useNavigate', () => {
- it('returns the navigate function', function () {
- let navigate;
- function HomePage() {
- navigate = useNavigate();
- return null;
- }
- const memoryHistory = createMemoryHistory();
- memoryHistory.push('/');
- render(
- <Router
- history={memoryHistory}
- render={props => {
- return (
- <RouteContext.Provider value={props}>
- <RouterContext {...props} />
- </RouteContext.Provider>
- );
- }}
- >
- <Route path="/" component={HomePage} />
- </Router>
- );
- expect(typeof navigate).toBe('function');
- });
- });
|