-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-utils.js
More file actions
33 lines (27 loc) · 796 Bytes
/
test-utils.js
File metadata and controls
33 lines (27 loc) · 796 Bytes
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
33
import React from 'react';
import { render as rtlRender } from '@testing-library/react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import reducer, {
initialState as filesInitialState,
} from './src/features/FileList/fileListSlice';
const mockState = {
files: filesInitialState,
};
const mockStore = createStore(reducer, mockState);
mockStore.dispatch = () => ({
files: {},
});
function render(
ui,
{ initialState = mockState, store = mockStore, ...renderOptions } = {}
) {
function Wrapper({ children }) {
return <Provider store={store}>{children}</Provider>;
}
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
}
// re-export everything
export * from '@testing-library/react';
// override render method
export { render };