summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-05 22:23:40 +0200
committerErik Larkö <erik@mullvad.net>2017-07-11 08:34:45 +0200
commitf7287bef9c3fca9fe2e2088648e589f3b6893da6 (patch)
tree98a475bc226b05432696cf8670a2a958c196f6fb /test
parenta96f21751907f50370b146aa92a893db9482f5f3 (diff)
downloadmullvadvpn-f7287bef9c3fca9fe2e2088648e589f3b6893da6.tar.xz
mullvadvpn-f7287bef9c3fca9fe2e2088648e589f3b6893da6.zip
New backend states
Diffstat (limited to 'test')
-rw-r--r--test/connect.spec.js16
-rw-r--r--test/mocks/ipc.js5
2 files changed, 15 insertions, 6 deletions
diff --git a/test/connect.spec.js b/test/connect.spec.js
index 56fdb76afc..13f4bef78a 100644
--- a/test/connect.spec.js
+++ b/test/connect.spec.js
@@ -43,25 +43,31 @@ describe('connect', () => {
}, done);
});
- it('should update the store on \'secured\' state from the backend', () => {
+ it('should correctly deduce \'connected\' from backend states', () => {
const { store, mockIpc } = setupBackendAndStore();
expect(store.getState().connection.status).not.to.equal('connected');
- mockIpc.sendNewState('secured');
+ mockIpc.sendNewState({ state: 'secured', target_state: 'secured' });
expect(store.getState().connection.status).to.equal('connected');
+ });
+
+ it('should correctly deduce \'connecting\' from backend states', () => {
+ const { store, mockIpc } = setupBackendAndStore();
+ expect(store.getState().connection.status).not.to.equal('connecting');
+ mockIpc.sendNewState({ state: 'unsecured', target_state: 'secured' });
+ expect(store.getState().connection.status).to.equal('connecting');
});
- it('should update the store on \'unsecured\' state from the backend', () => {
+ it('should correctly deduce \'disconnected\' from backend states', () => {
const { store, mockIpc } = setupBackendAndStore();
store.dispatch(connectionActions.connectionChange({
status: 'connected',
}));
expect(store.getState().connection.status).not.to.equal('disconnected');
- mockIpc.sendNewState('unsecured');
+ mockIpc.sendNewState({ state: 'unsecured', target_state: 'unsecured' });
expect(store.getState().connection.status).to.equal('disconnected');
-
});
});
diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js
index cc6146be73..25c8cdf7fa 100644
--- a/test/mocks/ipc.js
+++ b/test/mocks/ipc.js
@@ -45,7 +45,10 @@ export function newMockIpc() {
}));
},
getState: () => {
- return new Promise(r => r('unsecured'));
+ return new Promise(r => r({
+ state: 'unsecured',
+ target_state:'unsecured',
+ }));
},
registerStateListener: (listener: (BackendState) => void) => {
stateListeners.push(listener);