diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-06-01 16:13:10 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-06-05 12:11:55 +0200 |
| commit | ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch) | |
| tree | b1f7754eb50896ab3681e35fa4e08be642b940c9 /test/login.spec.js | |
| parent | 5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff) | |
| download | mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip | |
Add formatted source code
Diffstat (limited to 'test/login.spec.js')
| -rw-r--r-- | test/login.spec.js | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/test/login.spec.js b/test/login.spec.js index 1efe89ae38..acb38db2eb 100644 --- a/test/login.spec.js +++ b/test/login.spec.js @@ -1,23 +1,31 @@ // @flow import { expect } from 'chai'; -import { setupBackendAndStore, setupBackendAndMockStore, checkNextTick, getLocation, failFast, check } from './helpers/ipc-helpers'; +import { + setupBackendAndStore, + setupBackendAndMockStore, + checkNextTick, + getLocation, + failFast, + check, +} from './helpers/ipc-helpers'; import { IpcChain } from './helpers/IpcChain'; import accountActions from '../app/redux/account/actions'; describe('Logging in', () => { - it('should validate the account number and then set it in the backend', (done) => { const { store, mockIpc, backend } = setupBackendAndStore(); const chain = new IpcChain(mockIpc); - chain.require('getAccountData') + chain + .require('getAccountData') .withInputValidation((an) => { expect(an).to.equal('123'); }) .done(); - chain.require('setAccount') + chain + .require('setAccount') .withInputValidation((an) => { expect(an).to.equal('123'); }) @@ -30,26 +38,28 @@ describe('Logging in', () => { it('should put the account data in the state', () => { const { store, backend, mockIpc } = setupBackendAndStore(); - mockIpc.getAccountData = () => new Promise(r => r({ - expiry: '2001-01-01T00:00:00Z', - })); + mockIpc.getAccountData = () => + new Promise((r) => + r({ + expiry: '2001-01-01T00:00:00Z', + }), + ); - return backend.login('123') - .then( () => { - const state = store.getState().account; - expect(state.status).to.equal('ok'); - expect(state.accountToken).to.equal('123'); - expect(state.expiry).to.equal('2001-01-01T00:00:00Z'); - }); + return backend.login('123').then(() => { + const state = store.getState().account; + expect(state.status).to.equal('ok'); + expect(state.accountToken).to.equal('123'); + expect(state.expiry).to.equal('2001-01-01T00:00:00Z'); + }); }); it('should indicate failure for non-existing accounts', (done) => { const { store, mockIpc, backend } = setupBackendAndStore(); - mockIpc.getAccountData = (_num) => new Promise((_, reject) => { - reject('NO SUCH ACCOUNT'); - }); - + mockIpc.getAccountData = (_num) => + new Promise((_, reject) => { + reject('NO SUCH ACCOUNT'); + }); store.dispatch(accountActions.login(backend, '123')); @@ -66,20 +76,15 @@ describe('Logging in', () => { store.dispatch(accountActions.login(backend, '123')); setTimeout(() => { - failFast(() => { expect(getLocation(store)).not.to.equal('/connect'); }, done); - }, 100); - setTimeout(() => { - check(() => { expect(getLocation(store)).to.equal('/connect'); }, done); - }, 1100); }); }); |
