diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-08-28 12:45:53 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-08-28 12:45:53 +0200 |
| commit | 37a070297994643bc837b540aeefa69d4e0a9323 (patch) | |
| tree | 4576a7ce00c79aedb4d2a56ca60d903ffef06620 /test | |
| parent | ed1c99e5124635a83e94f976e38da2a89116904d (diff) | |
| parent | 1bb871b2c523211735c7162f82475b60d1221086 (diff) | |
| download | mullvadvpn-37a070297994643bc837b540aeefa69d4e0a9323.tar.xz mullvadvpn-37a070297994643bc837b540aeefa69d4e0a9323.zip | |
Merge branch 'connect-tests-3'
Diffstat (limited to 'test')
| -rw-r--r-- | test/components/Connect.spec.js | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js index 1f98ac87a2..1032d4ddf8 100644 --- a/test/components/Connect.spec.js +++ b/test/components/Connect.spec.js @@ -7,10 +7,12 @@ import { mount } from 'enzyme'; import Connect from '../../app/components/Connect'; import Header from '../../app/components/HeaderBar'; +import type { ReactWrapper } from 'enzyme'; + describe('components/Connect', () => { it('shows unsecured hints when not connected', () => { - const component = mount( <Connect {...defaultProps} /> ); + const component = renderNotConnected(); const header = component.find(Header); const securityMessage = component.find('.connect__status-security--unsecured'); @@ -22,17 +24,52 @@ describe('components/Connect', () => { }); it('invokes the onConnect prop', (done) => { - const props = Object.assign({}, defaultProps, { + const component = renderNotConnected({ onConnect: done, }); - - const component = mount( <Connect {...props} /> ); const connectButton = component.find('.button .button--positive'); connectButton.simulate('click'); }); + + it('shows the connection location information when connected', () => { + const component = renderConnected({}, { + country: 'sweden', + city: 'gothenburg', + clientIp: '1.2.3.4', + }); + const countryAndCity = component.find('.connect__status-location'); + const ipAddr = component.find('.connect__status-ipaddress'); + + expect(countryAndCity.text()).to.contain('sweden'); + expect(countryAndCity.text()).to.contain('gothenburg'); + expect(ipAddr.text()).to.contain('1.2.3.4'); + }); }); +function renderNotConnected(customProps, customConnectionProps) { + const connection = Object.assign({}, defaultConnection, { + status: 'disconnected', + }, customConnectionProps); + + const props = Object.assign({}, customProps, {connection}); + return renderWithProps(props); +} + +function renderConnected(customProps, customConnectionProps) { + const connection = Object.assign({}, defaultConnection, { + status: 'connected', + }, customConnectionProps); + + const props = Object.assign({}, customProps, {connection}); + return renderWithProps(props); +} + +function renderWithProps(customProps): ReactWrapper { + const props = Object.assign({}, defaultProps, customProps); + return mount( <Connect { ...props } /> ); +} + const noop = () => {}; const defaultServer = { address: '', |
