forked from mattermost/mattermost-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_store.js
43 lines (34 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
39
40
41
42
43
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createTransform} from 'redux-persist';
import {AsyncNodeStorage} from 'redux-persist-node-storage';
import configureStore from '@store';
export default async function testConfigureStore(preloadedState) {
const storageTransform = createTransform(
() => ({}),
() => ({}),
);
const persistConfig = {
key: 'root',
storage: new AsyncNodeStorage('./.tmp'),
whitelist: [],
serialize: true,
deserialize: true,
transforms: [
storageTransform,
],
};
const {store} = configureStore(null, preloadedState, persistConfig, {enableBuffer: false});
const wait = () => new Promise((resolve) => setTimeout(resolve), 300); //eslint-disable-line
await wait();
return store;
}
// This should probably be replaced by redux-mock-store like the web app
export function mockDispatch(dispatch) {
const mocked = (action) => {
dispatch(action);
mocked.actions.push(action);
};
mocked.actions = [];
return mocked;
}