summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-19 14:35:18 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-20 15:36:17 +0200
commit46672191cb3ee17b82f4af412bd00c75e138eaf9 (patch)
treea354207aab5af7a270ae2a8e80d5cecccf68d0c2 /test
parent46125ddac41dd0b5915940a5e9cf0e9b547c56d9 (diff)
downloadmullvadvpn-46672191cb3ee17b82f4af412bd00c75e138eaf9.tar.xz
mullvadvpn-46672191cb3ee17b82f4af412bd00c75e138eaf9.zip
Make expect and spy global for all tests
Diffstat (limited to 'test')
-rw-r--r--test/.eslintrc9
-rw-r--r--test/auth.spec.js1
-rw-r--r--test/autologin.spec.js1
-rw-r--r--test/components/Account.spec.js3
-rw-r--r--test/components/AccountInput.spec.js2
-rw-r--r--test/components/Connect.spec.js3
-rw-r--r--test/components/HeaderBar.spec.js1
-rw-r--r--test/components/Login.spec.js1
-rw-r--r--test/components/Preferences.spec.js3
-rw-r--r--test/components/SelectLocation.spec.js1
-rw-r--r--test/components/Settings.spec.js3
-rw-r--r--test/components/Support.spec.js3
-rw-r--r--test/components/Switch.spec.js1
-rw-r--r--test/connect.spec.js1
-rw-r--r--test/helpers/IpcChain.js1
-rw-r--r--test/ipc.spec.js6
-rw-r--r--test/keyframe-animation.spec.js39
-rw-r--r--test/login.spec.js1
-rw-r--r--test/logout.spec.js1
-rw-r--r--test/relay-settings-builder.spec.js1
-rw-r--r--test/setup/renderer.js3
-rw-r--r--test/transition-rule.spec.js2
22 files changed, 51 insertions, 36 deletions
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 0000000000..8f377410fc
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,9 @@
+{
+ "env": {
+ "mocha": true
+ },
+ "globals": {
+ "expect": true,
+ "spy": true
+ }
+} \ No newline at end of file
diff --git a/test/auth.spec.js b/test/auth.spec.js
index c4330b4559..e6b2c25486 100644
--- a/test/auth.spec.js
+++ b/test/auth.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect, spy } from 'chai';
import { setupIpcAndStore, setupBackendAndStore } from './helpers/ipc-helpers';
import { IpcChain } from './helpers/IpcChain';
import { Backend } from '../app/lib/backend';
diff --git a/test/autologin.spec.js b/test/autologin.spec.js
index 06a6ec7eb3..60c5cc5bde 100644
--- a/test/autologin.spec.js
+++ b/test/autologin.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import { setupBackendAndStore, setupBackendAndMockStore, getLocation } from './helpers/ipc-helpers';
import { IpcChain } from './helpers/IpcChain';
diff --git a/test/components/Account.spec.js b/test/components/Account.spec.js
index 2476cc35e0..2c0979bb50 100644
--- a/test/components/Account.spec.js
+++ b/test/components/Account.spec.js
@@ -1,7 +1,6 @@
// @flow
-import { expect } from 'chai';
-import React from 'react';
+import * as React from 'react';
import { shallow } from 'enzyme';
import Account from '../../app/components/Account';
import type { AccountProps } from '../../app/components/Account';
diff --git a/test/components/AccountInput.spec.js b/test/components/AccountInput.spec.js
index eface9c8c6..2f6ead1b45 100644
--- a/test/components/AccountInput.spec.js
+++ b/test/components/AccountInput.spec.js
@@ -1,5 +1,5 @@
// @flow
-import { expect } from 'chai';
+
import { createKeyEvent } from '../helpers/dom-events';
import * as React from 'react';
import { shallow } from 'enzyme';
diff --git a/test/components/Connect.spec.js b/test/components/Connect.spec.js
index 64771248b6..d21a8eb510 100644
--- a/test/components/Connect.spec.js
+++ b/test/components/Connect.spec.js
@@ -1,7 +1,6 @@
// @flow
-import { expect } from 'chai';
-import React from 'react';
+import * as React from 'react';
import { shallow } from 'enzyme';
import Connect from '../../app/components/Connect';
diff --git a/test/components/HeaderBar.spec.js b/test/components/HeaderBar.spec.js
index b5fb6bb7b6..6fcbfb54d7 100644
--- a/test/components/HeaderBar.spec.js
+++ b/test/components/HeaderBar.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import React from 'react';
import { shallow } from 'enzyme';
import HeaderBar from '../../app/components/HeaderBar';
diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js
index 04f3cbdd92..90bb70f4b3 100644
--- a/test/components/Login.spec.js
+++ b/test/components/Login.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect, spy } from 'chai';
import * as React from 'react';
import { shallow } from 'enzyme';
diff --git a/test/components/Preferences.spec.js b/test/components/Preferences.spec.js
index 3b6976a1ec..280b24ccd7 100644
--- a/test/components/Preferences.spec.js
+++ b/test/components/Preferences.spec.js
@@ -1,7 +1,6 @@
// @flow
-import { expect } from 'chai';
-import React from 'react';
+import * as React from 'react';
import { shallow } from 'enzyme';
import Preferences from '../../app/components/Preferences';
diff --git a/test/components/SelectLocation.spec.js b/test/components/SelectLocation.spec.js
index 8310d52b97..c9a1f08864 100644
--- a/test/components/SelectLocation.spec.js
+++ b/test/components/SelectLocation.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import * as React from 'react';
import { shallow } from 'enzyme';
import SelectLocation from '../../app/components/SelectLocation';
diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js
index 61ca47e3e4..f564902c2a 100644
--- a/test/components/Settings.spec.js
+++ b/test/components/Settings.spec.js
@@ -1,7 +1,6 @@
// @flow
-import { expect } from 'chai';
-import React from 'react';
+import * as React from 'react';
import Settings from '../../app/components/Settings';
import { shallow } from 'enzyme';
diff --git a/test/components/Support.spec.js b/test/components/Support.spec.js
index c06ac0b1d8..ce1efb2b75 100644
--- a/test/components/Support.spec.js
+++ b/test/components/Support.spec.js
@@ -1,7 +1,6 @@
// @flow
-import { expect, spy } from 'chai';
-import React from 'react';
+import * as React from 'react';
import Support from '../../app/components/Support';
import { shallow } from 'enzyme';
import type { SupportProps } from '../../app/components/Support';
diff --git a/test/components/Switch.spec.js b/test/components/Switch.spec.js
index e1242d74df..44794d9bba 100644
--- a/test/components/Switch.spec.js
+++ b/test/components/Switch.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import * as React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils, { Simulate } from 'react-dom/test-utils';
diff --git a/test/connect.spec.js b/test/connect.spec.js
index 0b5b33be53..f1621dbeb6 100644
--- a/test/connect.spec.js
+++ b/test/connect.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import connectionActions from '../app/redux/connection/actions';
import { setupBackendAndStore, checkNextTick } from './helpers/ipc-helpers';
diff --git a/test/helpers/IpcChain.js b/test/helpers/IpcChain.js
index efd80d39de..1505621cc0 100644
--- a/test/helpers/IpcChain.js
+++ b/test/helpers/IpcChain.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import { check, failFast } from './ipc-helpers';
export class IpcChain {
diff --git a/test/ipc.spec.js b/test/ipc.spec.js
index 43d6e9e2f4..1c8b19b5a6 100644
--- a/test/ipc.spec.js
+++ b/test/ipc.spec.js
@@ -2,8 +2,6 @@
import Ipc from '../app/lib/jsonrpc-ws-ipc';
import jsonrpc from 'jsonrpc-lite';
-import { expect } from 'chai';
-import assert from 'assert';
import type { JsonRpcMessage } from '../app/lib/jsonrpc-ws-ipc';
describe('The IPC server', () => {
@@ -45,7 +43,9 @@ describe('The IPC server', () => {
const decoy = ipc
.send('a decoy', [], 1)
- .then(() => assert(false, 'Should not be called'))
+ .then(() => {
+ throw new Error('Should not be called');
+ })
.catch((e) => {
if (e.name !== 'TimeOutError') {
throw e;
diff --git a/test/keyframe-animation.spec.js b/test/keyframe-animation.spec.js
index 5153719497..926bb79625 100644
--- a/test/keyframe-animation.spec.js
+++ b/test/keyframe-animation.spec.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+// @flow
+
import KeyframeAnimation from '../app/lib/keyframe-animation';
import { nativeImage } from 'electron';
@@ -15,7 +16,9 @@ describe('lib/keyframe-animation', function() {
it('should play sequence', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([0, 1, 2, 3, 4]);
expect(animation._currentFrame).to.be.equal(4);
@@ -28,7 +31,9 @@ describe('lib/keyframe-animation', function() {
it('should play one frame', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([3]);
expect(animation._currentFrame).to.be.equal(3);
@@ -41,7 +46,9 @@ describe('lib/keyframe-animation', function() {
it('should play sequence with custom frames', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([2, 3, 4]);
expect(animation._currentFrame).to.be.equal(4);
@@ -57,7 +64,9 @@ describe('lib/keyframe-animation', function() {
it('should play sequence with custom frames in reverse', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([4, 3, 2]);
expect(animation._currentFrame).to.be.equal(2);
@@ -74,7 +83,9 @@ describe('lib/keyframe-animation', function() {
it('should begin from current state starting below range', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([0, 1, 2, 3, 4]);
expect(animation._currentFrame).to.be.equal(4);
@@ -94,7 +105,9 @@ describe('lib/keyframe-animation', function() {
it('should begin from current state starting below range reverse', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([0, 1, 2, 3]);
expect(animation._currentFrame).to.be.equal(3);
@@ -115,7 +128,9 @@ describe('lib/keyframe-animation', function() {
it('should begin from current state starting above range', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([4, 3, 2]);
expect(animation._currentFrame).to.be.equal(2);
@@ -135,7 +150,9 @@ describe('lib/keyframe-animation', function() {
it('should begin from current state starting above range reverse', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([4, 3, 2, 1]);
expect(animation._currentFrame).to.be.equal(1);
@@ -156,7 +173,9 @@ describe('lib/keyframe-animation', function() {
it('should play sequence in reverse', (done) => {
let seq = [];
const animation = newAnimation();
- animation.onFrame = () => seq.push(animation._currentFrame);
+ animation.onFrame = () => {
+ seq.push(animation._currentFrame);
+ };
animation.onFinish = () => {
expect(seq).to.be.deep.equal([4, 3, 2, 1, 0]);
expect(animation._currentFrame).to.be.equal(0);
diff --git a/test/login.spec.js b/test/login.spec.js
index 8c99111343..68db14494b 100644
--- a/test/login.spec.js
+++ b/test/login.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import {
setupBackendAndStore,
setupBackendAndMockStore,
diff --git a/test/logout.spec.js b/test/logout.spec.js
index 4b0edaa0ca..65bc3aba09 100644
--- a/test/logout.spec.js
+++ b/test/logout.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import {
setupBackendAndStore,
setupBackendAndMockStore,
diff --git a/test/relay-settings-builder.spec.js b/test/relay-settings-builder.spec.js
index a2d69ceca6..ace01a978c 100644
--- a/test/relay-settings-builder.spec.js
+++ b/test/relay-settings-builder.spec.js
@@ -1,6 +1,5 @@
// @flow
-import { expect } from 'chai';
import RelaySettingsBuilder from '../app/lib/relay-settings-builder';
describe('Relay settings builder', () => {
diff --git a/test/setup/renderer.js b/test/setup/renderer.js
index 42b8d7e163..acfa87b7ed 100644
--- a/test/setup/renderer.js
+++ b/test/setup/renderer.js
@@ -8,3 +8,6 @@ chai.use(spies);
Enzyme.configure({
adapter: new Adapter(),
});
+
+global.expect = chai.expect;
+global.spy = chai.spy;
diff --git a/test/transition-rule.spec.js b/test/transition-rule.spec.js
index 00fffff01e..f36c44182e 100644
--- a/test/transition-rule.spec.js
+++ b/test/transition-rule.spec.js
@@ -1,5 +1,5 @@
// @flow
-import { expect } from 'chai';
+
import TransitionRule from '../app/lib/transition-rule';
describe('TransitionRule', () => {