diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/components/Connect.spec.js | 14 | ||||
| -rw-r--r-- | test/components/SelectLocation.spec.js | 8 | ||||
| -rw-r--r-- | test/components/Settings.spec.js | 8 | ||||
| -rw-r--r-- | test/connect.spec.js | 25 | ||||
| -rw-r--r-- | test/mocks/ipc.js | 10 | ||||
| -rw-r--r-- | test/reducers.spec.js | 21 |
6 files changed, 42 insertions, 44 deletions
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js index 07c67a57bc..4b84b3b8da 100644 --- a/test/components/Connect.spec.js +++ b/test/components/Connect.spec.js @@ -106,7 +106,11 @@ describe('components/Connect', () => { const locationSwitcher = component.find('.connect__server'); component.setProps({ - preferredServer: 'se1.mullvad.net', + settings: { + relayConstraints: { + host: 'se1.mullvad.net', + }, + }, }); expect(locationSwitcher.text()).to.contain(servers['se1.mullvad.net'].name); }); @@ -181,6 +185,12 @@ const defaultProps = { getServerInfo: (_) => { return defaultServer; }, accountExpiry: '', - preferredServer: '', + settings: { + relayConstraints: { + host: 'www.example.com', + port: 'any', + protocol: 'any', + }, + }, connection: defaultConnection, }; diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js index 783a3adbf9..28c9299807 100644 --- a/test/components/SelectLocation.spec.js +++ b/test/components/SelectLocation.spec.js @@ -4,15 +4,17 @@ import { expect } from 'chai'; import React from 'react'; import ReactTestUtils, { Simulate } from 'react-dom/test-utils'; import SelectLocation from '../../app/components/SelectLocation'; -import { defaultServer } from '../../app/config'; import type { SettingsReduxState } from '../../app/redux/settings/reducers'; import type { SelectLocationProps } from '../../app/components/SelectLocation'; describe('components/SelectLocation', () => { const state: SettingsReduxState = { - autoSecure: true, - preferredServer: defaultServer + relayConstraints: { + host: 'any', + port: 'any', + protocol: 'any', + }, }; const makeProps = (state: SettingsReduxState, mergeProps: $Shape<SelectLocationProps>): SelectLocationProps => { diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js index f90d658f9b..85fd72ece5 100644 --- a/test/components/Settings.spec.js +++ b/test/components/Settings.spec.js @@ -4,7 +4,6 @@ import { expect } from 'chai'; import React from 'react'; import ReactTestUtils, { Simulate } from 'react-dom/test-utils'; import Settings from '../../app/components/Settings'; -import { defaultServer } from '../../app/config'; import type { AccountReduxState } from '../../app/redux/account/reducers'; import type { SettingsReduxState } from '../../app/redux/settings/reducers'; @@ -33,7 +32,11 @@ describe('components/Settings', () => { }; const settingsState: SettingsReduxState = { - preferredServer: defaultServer + relayConstraints: { + host: 'any', + port: 'any', + protocol: 'any', + }, }; const makeProps = (anAccountState: AccountReduxState, aSettingsState: SettingsReduxState, mergeProps: $Shape<SettingsProps> = {}): SettingsProps => { @@ -44,6 +47,7 @@ describe('components/Settings', () => { onClose: () => {}, onViewAccount: () => {}, onViewSupport: () => {}, + onViewAdvancedSettings: () => {}, onExternalLink: (_type) => {} }; return Object.assign({}, defaultProps, mergeProps); diff --git a/test/connect.spec.js b/test/connect.spec.js index 07e3091c6e..586df45980 100644 --- a/test/connect.spec.js +++ b/test/connect.spec.js @@ -7,14 +7,18 @@ import { IpcChain } from './helpers/IpcChain'; describe('connect', () => { - it('should invoke set_custom_relay and then connect in the backend', (done) => { + it('should invoke update_relay_constraints and then connect in the backend', (done) => { const { store, mockIpc, backend } = setupBackendAndStore(); const chain = new IpcChain(mockIpc); - chain.require('setCustomRelay') + chain.require('updateRelayConstraints') .withInputValidation( - (relayEndpoint) => { - expect(relayEndpoint).to.equal(arbitraryRelay); + relayEndpoint => { + if (relayEndpoint) { + expect(relayEndpoint.host.only).to.equal(arbitraryRelay); + } else { + expect.fail(); + } }, ) .done(); @@ -47,13 +51,8 @@ describe('connect', () => { it('should update the state with the server address', () => { const { store, backend } = setupBackendAndStore(); - const relay = { - host: 'www.example.com', - port: 1, - protocol: 'udp', - }; - return backend.connect(relay) + return backend.connect('www.example.com') .then( () => { const state = store.getState().connection; expect(state.status).to.equal('connecting'); @@ -93,8 +92,4 @@ describe('connect', () => { }); }); -const arbitraryRelay = { - host: 'www.example.com', - port: 1, - protocol: 'udp', -}; +const arbitraryRelay = 'www.example.com'; diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js index c02eb20de4..67c11c7366 100644 --- a/test/mocks/ipc.js +++ b/test/mocks/ipc.js @@ -28,7 +28,15 @@ export function newMockIpc() { setAccount: () => Promise.resolve(), - setCustomRelay: () => Promise.resolve(), + updateRelayConstraints: () => Promise.resolve(), + + getRelayContraints: () => Promise.resolve({ + host: { only: 'www.example.com' }, + tunnel: { openvpn: { + port: 'any', + protocol: 'any', + }}, + }), connect: () => Promise.resolve(), diff --git a/test/reducers.spec.js b/test/reducers.spec.js deleted file mode 100644 index 92392ad5d3..0000000000 --- a/test/reducers.spec.js +++ /dev/null @@ -1,21 +0,0 @@ -// @flow - -import { expect } from 'chai'; -import settingsReducer from '../app/redux/settings/reducers'; -import { defaultServer } from '../app/config'; - -describe('reducers', () => { - const previousState: any = {}; - - it('should handle SETTINGS_UPDATE', () => { - const action = { - type: 'UPDATE_SETTINGS', - newSettings: { - preferredServer: defaultServer - } - }; - const test = Object.assign({}, action.newSettings); - expect(settingsReducer(previousState, action)).to.deep.equal(test); - }); - -}); |
