Skip to content

Commit

Permalink
feat: Jest test wrapper component created, CypressTestUtils folder re…
Browse files Browse the repository at this point in the history
…located
  • Loading branch information
mkholjuraev committed Aug 13, 2024
1 parent 1d31fb2 commit a40800e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 1 deletion.
File renamed without changes.
33 changes: 33 additions & 0 deletions packages/utils/src/TestingUtils/JestUtils/TestWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import PropTypes from 'prop-types';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { IntlProvider } from 'react-intl';

const TestWrapper = ({ renderOptions = {}, children }) => {
const mockStore = configureStore();

return (
<IntlProvider locale="en">
<Provider store={renderOptions?.store || mockStore()}>
<MemoryRouter initialEntries={renderOptions?.initialEntries || ['/']}>
{renderOptions?.componentPath ? (
<Routes>
<Route path={renderOptions?.elementPath || '/'}>{children}</Route>
</Routes>
) : (
children
)}
</MemoryRouter>
</Provider>
</IntlProvider>
);
};

TestWrapper.propTypes = {
children: PropTypes.element,
renderOptions: PropTypes.object,
};

export default TestWrapper;
1 change: 1 addition & 0 deletions packages/utils/src/TestingUtils/JestUtils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TestWrapper';
3 changes: 2 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export * from './Registry';
export { default as routerParams } from './RouterParams';
export { default as RowLoader } from './RowLoader';
export { useInventory } from './useInventory';
export * from './CypressUtils';
export * from './TestingUtils/CypressUtils';
export * from './useInsightsNavigate';
export * from './useExportPDF';
export * from './usePromiseQueue';
export * from './useFetchBatched';
export * from './useSuspenseLoader';
export * from './TestingUtils/JestUtils';

0 comments on commit a40800e

Please sign in to comment.