diff options
| author | Andrei Mihailov <and.mikhaylov@gmail.com> | 2017-02-16 12:18:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-16 12:18:52 +0000 |
| commit | 4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3 (patch) | |
| tree | 8f7dfc5545c484472d3dc5138cddf6a810fa0558 /test | |
| parent | 5ba4a72e546747167e7ae815724ee2dd4b2ef8fb (diff) | |
| download | mullvadvpn-4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3.tar.xz mullvadvpn-4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3.zip | |
Feature/menubar popup window (#1)
Add menubar and tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/actions/user.spec.js | 31 | ||||
| -rw-r--r-- | test/lib/enum.spec.js | 36 |
2 files changed, 48 insertions, 19 deletions
diff --git a/test/actions/user.spec.js b/test/actions/user.spec.js index 259e862a6d..9bd93d4010 100644 --- a/test/actions/user.spec.js +++ b/test/actions/user.spec.js @@ -27,7 +27,7 @@ describe('actions', () => { const account = '1234'; const getState = () => ({}); let callCounter = 0; - const dispatch = chai.spy((action) => { + const dispatch = chai.spy(() => { callCounter += 1; if(callCounter == 2) { @@ -59,7 +59,7 @@ describe('actions', () => { const account = '1234'; const getState = () => ({}); let callCounter = 0; - const dispatch = chai.spy((action) => { + const dispatch = chai.spy(() => { callCounter += 1; if(callCounter == 2) { @@ -86,5 +86,32 @@ describe('actions', () => { action(dispatch, getState); }); + it('should log out', (done) => { + let callCount = 0; + const getState = () => ({ account: '1234', status: LoginState.ok }); + const dispatch = chai.spy( (u) => { + callCount += 1; + + if(callCount === 1) { + expect(dispatch).to.have.been.called.with({ + type: actions.loginChange.toString(), + payload: { + account: '', + status: LoginState.none, + error: null + } + }); + + done(); + } + }); + const backend = { + logout: () => Promise.resolve() + }; + const action = actions.logout(backend); + + action(dispatch, getState); + }); + }); }); diff --git a/test/lib/enum.spec.js b/test/lib/enum.spec.js index 0f5d6ee4d1..20de191d08 100644 --- a/test/lib/enum.spec.js +++ b/test/lib/enum.spec.js @@ -1,24 +1,26 @@ import { expect } from 'chai'; import Enum from '../../app/lib/enum'; -describe('enum', () => { - - it('should be able to compare values', () => { - const e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); - expect(e.NORTH).to.be.equal('NORTH'); - }); +describe('lib', () => { - it('should not be able to modify enum', () => { - let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); - expect(() => e.ANYWHERE = 'ANYWHERE').to.throw(); - }); + describe('enum', () => { + it('should be able to compare values', () => { + const e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); + expect(e.NORTH).to.be.equal('NORTH'); + }); - it('should be able to validate enum keys', () => { - let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); - expect(e.isValid('SOUTH')).to.be.true; - expect(e.isValid('ANYWHERE')).to.be.false; - expect(e.isValid()).to.be.false; - expect(e.isValid(null)).to.be.false; - }) + it('should not be able to modify enum', () => { + let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); + expect(() => e.ANYWHERE = 'ANYWHERE').to.throw(); + }); + + it('should be able to validate enum keys', () => { + let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST'); + expect(e.isValid('SOUTH')).to.be.true; + expect(e.isValid('ANYWHERE')).to.be.false; + expect(e.isValid()).to.be.false; + expect(e.isValid(null)).to.be.false; + }); + }); }); |
