Skip to content

Commit

Permalink
test: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Nov 22, 2023
1 parent 88d9945 commit 0c5fc63
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/components/manage/Blocks/Group/DefaultBody.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-intl-redux';
import DefaultBody from './DefaultBody';
import configureStore from 'redux-mock-store';
import '@testing-library/jest-dom/extend-expect';

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: () => ({
pathname: '/',
hash: '',
search: '',
}),
}));

jest.mock('@plone/volto/components', () => ({
BlocksForm: jest.fn(() => <div className="blocks-form">RenderBlocks</div>),
RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
}));

const mockStore = configureStore();
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
});

describe('DefaultBody', () => {
it('renders children', () => {
const props = {
data: {
variation: {},
},
metadata: {},
properties: {},
variation: {},
};

const { getByText } = render(
<Provider store={store}>
<DefaultBody {...props} />
</Provider>,
);
expect(getByText('RenderBlocks')).toBeInTheDocument();
});
});

0 comments on commit 0c5fc63

Please sign in to comment.