forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_store.js
38 lines (33 loc) · 1.14 KB
/
test_store.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
33
34
35
36
37
38
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Provider} from 'react-redux';
import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import {IntlProvider} from 'react-intl';
import {defaultIntl} from './helpers/intl-test-helper';
export default function testConfigureStore(initialState = {}) {
return configureStore([thunk])(initialState);
}
export function mockStore(initialState = {}, intl = defaultIntl) {
const store = testConfigureStore(initialState);
return {
store,
mountOptions: intl ? {
// eslint-disable-next-line react/prop-types
wrappingComponent: ({children, ...props}) => (
<IntlProvider {...props}>
<Provider store={store}>
{children}
</Provider>
</IntlProvider>
),
wrappingComponentProps: {
...intl,
},
} : {
wrappingComponent: Provider,
wrappingComponentProps: {store},
},
};
}