diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-07-23 16:29:19 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-07-23 16:29:19 +0200 |
| commit | 858c95cdf3bb94ff4e75eb63c8c982520a5fb629 (patch) | |
| tree | 850e39a41014918b89189be2c62283b78c099161 /test | |
| parent | 7a72cd6f6768716f9c38923cb6a668b81209d617 (diff) | |
| download | mullvadvpn-858c95cdf3bb94ff4e75eb63c8c982520a5fb629.tar.xz mullvadvpn-858c95cdf3bb94ff4e75eb63c8c982520a5fb629.zip | |
Fix tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/components/Account.spec.js | 15 | ||||
| -rw-r--r-- | test/components/HeaderBar.spec.js | 6 | ||||
| -rw-r--r-- | test/components/Login.spec.js | 7 | ||||
| -rw-r--r-- | test/components/Preferences.spec.js | 3 | ||||
| -rw-r--r-- | test/components/SelectLocation.spec.js | 10 | ||||
| -rw-r--r-- | test/components/Settings.spec.js | 27 | ||||
| -rw-r--r-- | test/components/Support.spec.js | 6 |
7 files changed, 33 insertions, 41 deletions
diff --git a/test/components/Account.spec.js b/test/components/Account.spec.js index 2c0979bb50..ef2ffe6d16 100644 --- a/test/components/Account.spec.js +++ b/test/components/Account.spec.js @@ -3,6 +3,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Account from '../../app/components/Account'; +import { BackBarItem } from '../../app/components/NavigationBar'; import type { AccountProps } from '../../app/components/Account'; describe('components/Account', () => { @@ -25,8 +26,10 @@ describe('components/Account', () => { const props = makeProps({ onClose: () => done(), }); - const component = getComponent(render(props), 'account__close'); - click(component); + const component = render(props) + .find(BackBarItem) + .dive(); + component.simulate('press'); }); it('should call logout callback', (done) => { @@ -34,7 +37,7 @@ describe('components/Account', () => { onLogout: () => done(), }); const component = getComponent(render(props), 'account__logout'); - click(component); + component.simulate('press'); }); it('should call "buy more" callback', (done) => { @@ -42,7 +45,7 @@ describe('components/Account', () => { onBuyMore: () => done(), }); const component = getComponent(render(props), 'account__buymore'); - click(component); + component.simulate('press'); }); it('should display "out of time" message when account expired', () => { @@ -67,7 +70,3 @@ function render(props) { function getComponent(container, testName) { return container.findWhere((n) => n.prop('testName') === testName); } - -function click(component) { - component.prop('onPress')(); -} diff --git a/test/components/HeaderBar.spec.js b/test/components/HeaderBar.spec.js index 6fcbfb54d7..a8eca00d53 100644 --- a/test/components/HeaderBar.spec.js +++ b/test/components/HeaderBar.spec.js @@ -43,7 +43,7 @@ describe('components/HeaderBar', () => { onSettings: () => done(), }); const settingsButton = getComponent(component, 'headerbar__settings'); - click(settingsButton); + settingsButton.simulate('press'); }); }); @@ -58,7 +58,3 @@ function getComponent(container, testName) { function hasChild(container, testName) { return getComponent(container, testName).length > 0; } - -function click(component) { - component.prop('onPress')(); -} diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js index 76acbd6330..0db789c55d 100644 --- a/test/components/Login.spec.js +++ b/test/components/Login.spec.js @@ -59,7 +59,8 @@ describe('components/Login', () => { }, }); - click(getComponent(component, 'account-input-button')); + const accountInputButton = getComponent(component, 'account-input-button'); + accountInputButton.simulate('press'); }); }); @@ -79,7 +80,3 @@ const defaultProps = { function getComponent(container, testName) { return container.findWhere((n) => n.prop('testName') === testName); } - -function click(component) { - component.prop('onPress')(); -} diff --git a/test/components/Preferences.spec.js b/test/components/Preferences.spec.js index f8c38f9493..51be0dc473 100644 --- a/test/components/Preferences.spec.js +++ b/test/components/Preferences.spec.js @@ -3,12 +3,13 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Preferences from '../../app/components/Preferences'; +import { BackBarItem } from '../../app/components/NavigationBar'; 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' }); + const button = component.find(BackBarItem).dive(); expect(button).to.have.length(1); button.simulate('press'); }); diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js index dbfe15221a..bb5256cf54 100644 --- a/test/components/SelectLocation.spec.js +++ b/test/components/SelectLocation.spec.js @@ -64,7 +64,7 @@ describe('components/SelectLocation', () => { onClose: () => done(), }); const node = getComponent(render(props), 'close'); - click(node); + node.simulate('press'); }); it('should call select callback for country', (done) => { @@ -82,7 +82,7 @@ describe('components/SelectLocation', () => { }); const elements = getComponent(render(props), 'country'); expect(elements).to.have.length(1); - click(elements.at(0)); + elements.at(0).simulate('press'); }); it('should call select callback for city', (done) => { @@ -100,14 +100,10 @@ describe('components/SelectLocation', () => { }); const elements = getComponent(render(props), 'city'); expect(elements).to.have.length(2); - click(elements.at(0)); + elements.at(0).simulate('press'); }); }); function getComponent(container, testName) { return container.findWhere((n) => n.prop('testName') === testName); } - -function click(component) { - component.prop('onPress')(); -} diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js index 2a152e1cc8..9edf46fcc3 100644 --- a/test/components/Settings.spec.js +++ b/test/components/Settings.spec.js @@ -1,8 +1,9 @@ // @flow import * as React from 'react'; -import Settings from '../../app/components/Settings'; import { shallow } from 'enzyme'; +import Settings from '../../app/components/Settings'; +import { CloseBarItem } from '../../app/components/NavigationBar'; import type { AccountReduxState } from '../../app/redux/account/reducers'; import type { SettingsReduxState } from '../../app/redux/settings/reducers'; @@ -124,8 +125,10 @@ describe('components/Settings', () => { const props = makeProps(loggedOutAccountState, settingsState, { onClose: () => done(), }); - const component = getComponent(render(props), 'settings__close'); - click(component); + const component = render(props) + .find(CloseBarItem) + .dive(); + component.simulate('press'); }); it('should call quit callback', (done) => { @@ -133,7 +136,7 @@ describe('components/Settings', () => { onQuit: () => done(), }); const component = getComponent(render(props), 'settings__quit'); - click(component); + component.simulate('press'); }); it('should call account callback', (done) => { @@ -141,7 +144,7 @@ describe('components/Settings', () => { onViewAccount: () => done(), }); const component = getComponent(render(props), 'settings__account_paid_until_button'); - click(component); + component.simulate('press'); }); it('should call advanced settings callback', (done) => { @@ -149,7 +152,7 @@ describe('components/Settings', () => { onViewAdvancedSettings: () => done(), }); const component = getComponent(render(props), 'settings__advanced'); - click(component); + component.simulate('press'); }); it('should call preferences callback', (done) => { @@ -157,7 +160,7 @@ describe('components/Settings', () => { onViewPreferences: () => done(), }); const component = getComponent(render(props), 'settings__preferences'); - click(component); + component.simulate('press'); }); it('should call support callback', (done) => { @@ -165,7 +168,7 @@ describe('components/Settings', () => { onViewSupport: () => done(), }); const component = getComponent(render(props), 'settings__view_support'); - click(component); + component.simulate('press'); }); it('should call external links callback', () => { @@ -176,7 +179,9 @@ describe('components/Settings', () => { }, }); const container = getComponent(render(props), 'settings__external_link'); - container.find({ testName: 'settings__external_link' }).forEach((element) => click(element)); + container + .find({ testName: 'settings__external_link' }) + .forEach((element) => element.simulate('press')); expect(collectedExternalLinkTypes).to.include.ordered.members(['faq', 'guides']); }); @@ -189,7 +194,3 @@ function render(props) { function getComponent(container, testName) { return container.findWhere((n) => n.prop('testName') === testName); } - -function click(component) { - component.prop('onPress')(); -} diff --git a/test/components/Support.spec.js b/test/components/Support.spec.js index 59ddc25606..23172d3403 100644 --- a/test/components/Support.spec.js +++ b/test/components/Support.spec.js @@ -4,14 +4,16 @@ import * as React from 'react'; import Support from '../../app/components/Support'; import { shallow } from 'enzyme'; import type { SupportProps } from '../../app/components/Support'; +import { BackBarItem } from '../../app/components/NavigationBar'; describe('components/Support', () => { it('should call close callback', () => { const props = makeProps({ onClose: spy() }); const component = shallow(<Support {...props} />); - const closeButton = component.find({ testName: 'support__close' }); - click(closeButton); + const closeButton = component.find(BackBarItem).dive(); + closeButton.simulate('press'); + expect(props.onClose).to.have.been.called.once; }); |
