Skip to content

Commit

Permalink
mock react-router-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
dobri1408 committed Mar 27, 2024
1 parent 89483de commit f6a33ab
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/components/Blocks/Hero/Edit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@ import config from '@plone/volto/registry';
import '@testing-library/jest-dom/extend-expect';

const mockStore = configureStore([]);

jest.mock('@plone/volto-slate/editor/SlateEditor', () => {
return {
__esModule: true,
default: ({ placeholder, children, onChange, onFocus }) => (
<div
onChange={(target) => onChange(target)}
onFocus={() => onFocus()}
id="test"
>
<div>{placeholder}</div>
{children}
</div>
),
};
});

const observe = jest.fn();
const unobserve = jest.fn();

jest.mock('react-router-dom', () => ({
useLocation: jest.fn().mockReturnValue({
pathname: '/test',
search: '',
hash: '',
state: null,
key: 'test',
}),
}));

window.IntersectionObserver = jest.fn((callback) => ({
observe,
unobserve,
Expand Down

0 comments on commit f6a33ab

Please sign in to comment.