forked from City-of-Helsinki/servicemap-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jestUtils.js
32 lines (28 loc) · 929 Bytes
/
jestUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { ThemeProvider } from '@mui/material/styles';
import { render } from '@testing-library/react';
import React from 'react';
import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import finnish from './src/i18n/fi';
import themes from './src/themes';
const mockStore = configureStore([]);
// Mock props for intl provider
const intlMock = {
locale: 'fi',
messages: finnish,
wrapRichTextChunksInFragment: false,
};
const Providers = (mockState) => ({ children }) => {
const store = mockStore(mockState);
return (
<Provider store={store}>
<IntlProvider {...intlMock}>
<ThemeProvider theme={themes.SMThemeTku}>
{children}
</ThemeProvider>
</IntlProvider>
</Provider>
);
}
export const getRenderWithProviders = mockState => component => render(component, { wrapper: Providers(mockState) });