summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-08-22 15:06:03 +0200
committerErik Larkö <erik@mullvad.net>2017-08-28 07:31:59 +0200
commit1bb871b2c523211735c7162f82475b60d1221086 (patch)
tree4576a7ce00c79aedb4d2a56ca60d903ffef06620 /test
parented1c99e5124635a83e94f976e38da2a89116904d (diff)
downloadmullvadvpn-1bb871b2c523211735c7162f82475b60d1221086.tar.xz
mullvadvpn-1bb871b2c523211735c7162f82475b60d1221086.zip
Refactor tests and add first location test
Diffstat (limited to 'test')
-rw-r--r--test/components/Connect.spec.js45
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: '',