diff options
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(), |
