diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-01 12:18:28 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-01 12:18:28 +0000 |
| commit | 61b84e23036b3dbd032ce65b2a6021f531eaed03 (patch) | |
| tree | 358dbc4c5225db778152f305707d5b70a0b95453 /test/support.js | |
| parent | 4c4385d6046f0540d5520e38d5a5ea8c9cb709b3 (diff) | |
| download | mullvadvpn-61b84e23036b3dbd032ce65b2a6021f531eaed03.tar.xz mullvadvpn-61b84e23036b3dbd032ce65b2a6021f531eaed03.zip | |
Move mock helpers to test/support
Diffstat (limited to 'test/support.js')
| -rw-r--r-- | test/support.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/support.js b/test/support.js new file mode 100644 index 0000000000..e60de376e4 --- /dev/null +++ b/test/support.js @@ -0,0 +1,40 @@ +import configureMockStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import Backend from '../app/lib/backend'; +import { LoginState, ConnectionState, defaultServer } from '../app/constants'; + +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); + }); +}; |
