blob: 10387465d87babac359d031b8ed28327f256c55f (
plain)
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
|
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import Backend from '../app/lib/backend';
import { defaultServer } from '../app/config';
import { LoginState, ConnectionState } from '../app/enums';
const middlewares = [ thunk ];
export const mockStore = configureMockStore(middlewares);
export const mockState = () => {
return {
user: {
account: null,
status: LoginState.none,
error: null
},
connect: {
status: ConnectionState.disconnected,
serverAddress: null,
clientIp: null
},
settings: {
autoSecure: false,
preferredServer: defaultServer
}
};
};
export const mockBackend = (store) => {
const backend = new Backend();
// patch backend
backend.syncWithReduxStore(store);
return backend;
};
export const filterIpUpdateActions = (actions) => {
return actions.filter((action) => {
return !(action.type === 'CONNECTION_CHANGE' && action.payload.clientIp);
});
};
|