summaryrefslogtreecommitdiffhomepage
path: root/test/support.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-01 12:18:28 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-01 12:18:28 +0000
commit61b84e23036b3dbd032ce65b2a6021f531eaed03 (patch)
tree358dbc4c5225db778152f305707d5b70a0b95453 /test/support.js
parent4c4385d6046f0540d5520e38d5a5ea8c9cb709b3 (diff)
downloadmullvadvpn-61b84e23036b3dbd032ce65b2a6021f531eaed03.tar.xz
mullvadvpn-61b84e23036b3dbd032ce65b2a6021f531eaed03.zip
Move mock helpers to test/support
Diffstat (limited to 'test/support.js')
-rw-r--r--test/support.js40
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);
+ });
+};