diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-01-03 12:43:36 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-01-03 12:43:36 +0100 |
| commit | d19f790931beca0dcc62ae84f16d45b74d69a9c8 (patch) | |
| tree | 42f2ddc38820c72517d1598835da718b583d07d9 /test | |
| parent | d9f182e02742f9266941e4263e3e8f9cd92f6d32 (diff) | |
| parent | 9c1589392d08c31bd4cc95f1e727c705bfb6900a (diff) | |
| download | mullvadvpn-d19f790931beca0dcc62ae84f16d45b74d69a9c8.tar.xz mullvadvpn-d19f790931beca0dcc62ae84f16d45b74d69a9c8.zip | |
Merge branch 'add-lan-sharing'
Diffstat (limited to 'test')
| -rw-r--r-- | test/components/Connect.spec.js | 1 | ||||
| -rw-r--r-- | test/components/Preferences.spec.js | 29 | ||||
| -rw-r--r-- | test/components/SelectLocation.spec.js | 1 | ||||
| -rw-r--r-- | test/components/Settings.spec.js | 18 | ||||
| -rw-r--r-- | test/mocks/ipc.js | 10 |
5 files changed, 56 insertions, 3 deletions
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js index 4fcc3c6f60..ed8c17982a 100644 --- a/test/components/Connect.spec.js +++ b/test/components/Connect.spec.js @@ -161,6 +161,7 @@ const defaultProps: ConnectProps = { position: [0, 0], }] }], + allowLan: false, }, connection: { status: 'disconnected', diff --git a/test/components/Preferences.spec.js b/test/components/Preferences.spec.js new file mode 100644 index 0000000000..cad039df32 --- /dev/null +++ b/test/components/Preferences.spec.js @@ -0,0 +1,29 @@ +// @flow + +import { expect } from 'chai'; +import React from 'react'; +import { shallow } from 'enzyme'; +import Preferences from '../../app/components/Preferences'; + +require('../setup/enzyme'); + +describe('components/Preferences', () => { + + it('Should call close handler', (done) => { + const props = makeProps({ onClose: done }); + const component = shallow(<Preferences { ...props } />); + const button = component.find({ testName: 'closeButton' }); + expect(button).to.have.length(1); + button.simulate('press'); + }); + +}); + +function makeProps(props) { + return { + onClose: () => {}, + onChangeAllowLan: () => {}, + allowLan: false, + ...props + }; +} diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js index 1abdf515d9..459eb366ce 100644 --- a/test/components/SelectLocation.spec.js +++ b/test/components/SelectLocation.spec.js @@ -28,6 +28,7 @@ describe('components/SelectLocation', () => { hasActiveRelays: true, }], }], + allowLan: false, }; const makeProps = (state: SettingsReduxState, mergeProps: $Shape<SelectLocationProps>): SelectLocationProps => { diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js index 7f949cb6c3..415be57fd2 100644 --- a/test/components/Settings.spec.js +++ b/test/components/Settings.spec.js @@ -45,6 +45,7 @@ describe('components/Settings', () => { }, }, relayLocations: [], + allowLan: false, }; const makeProps = (anAccountState: AccountReduxState, aSettingsState: SettingsReduxState, mergeProps: $Shape<SettingsProps> = {}): SettingsProps => { @@ -56,6 +57,7 @@ describe('components/Settings', () => { onViewAccount: () => {}, onViewSupport: () => {}, onViewAdvancedSettings: () => {}, + onViewPreferences: () => {}, onExternalLink: (_type) => {} }; return Object.assign({}, defaultProps, mergeProps); @@ -139,6 +141,22 @@ describe('components/Settings', () => { click(component); }); + it('should call advanced settings callback', (done) => { + const props = makeProps(loggedInAccountState, settingsState, { + onViewAdvancedSettings: () => done() + }); + const component = getComponent(render(props), 'settings__advanced'); + click(component); + }); + + it('should call preferences callback', (done) => { + const props = makeProps(loggedInAccountState, settingsState, { + onViewPreferences: () => done() + }); + const component = getComponent(render(props), 'settings__preferences'); + click(component); + }); + it('should call support callback', (done) => { const props = makeProps(loggedInAccountState, settingsState, { onViewSupport: () => done() diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js index ede4bd37b7..fc035f55ed 100644 --- a/test/mocks/ipc.js +++ b/test/mocks/ipc.js @@ -24,6 +24,10 @@ export function newMockIpc() { expiry: '', }), + getRelayLocations: () => Promise.resolve({ + countries: [], + }), + getAccount: () => Promise.resolve('1111'), setAccount: () => Promise.resolve(), @@ -42,9 +46,9 @@ export function newMockIpc() { }, }), - getRelayLocations: () => Promise.resolve({ - countries: [], - }), + setAllowLan: (_allowLan: boolean) => Promise.resolve(), + + getAllowLan: () => Promise.resolve(true), connect: () => Promise.resolve(), |
