refactoring node 24
This commit is contained in:
@@ -3,3 +3,28 @@
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
||||
import React from 'react';
|
||||
|
||||
jest.mock('react-router-dom', () => {
|
||||
const navigate = jest.fn();
|
||||
|
||||
const PassThrough = ({ children }) => <>{children}</>;
|
||||
|
||||
const Route = ({ element = null, children = null }) => element || children || null;
|
||||
|
||||
const Link = ({ children, ...props }) => (
|
||||
<a {...props} data-mock-link="true">
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
|
||||
return {
|
||||
BrowserRouter: PassThrough,
|
||||
Routes: PassThrough,
|
||||
Route,
|
||||
Navigate: () => null,
|
||||
Link,
|
||||
useLocation: () => ({ pathname: '/' }),
|
||||
useNavigate: () => navigate
|
||||
};
|
||||
}, { virtual: true });
|
||||
|
||||
Reference in New Issue
Block a user