Skip to content

Commit

Permalink
Merge pull request #812 from h3poteto/iss-209
Browse files Browse the repository at this point in the history
refs #209 Add Authorize store tests
  • Loading branch information
h3poteto committed Dec 29, 2018
2 parents ded33d6 + ce5071c commit b4cebbf
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/unit/store/Authorize.spec.js
@@ -0,0 +1,31 @@
import Authorize from '@/store/Authorize'
import { ipcMain } from '~/spec/mock/electron'

describe('Authorize', () => {
describe('actions', () => {
describe('error', () => {
it('should return error', async () => {
ipcMain.once('get-access-token', (event, code) => {
event.sender.send('error-get-access-token', new AccessTokenError())
})
const commitMock = jest.fn()
await Authorize.actions.submit({ commit: commitMock }, 'code')
.catch((err) => {
expect(err instanceof AccessTokenError).toEqual(true)
})
})
})
describe('success', () => {
it('should return id', async () => {
ipcMain.once('get-access-token', (event, code) => {
event.sender.send('response-get-access-token', 'abcd')
})
const commitMock = jest.fn()
const id = await Authorize.actions.submit({ commit: commitMock }, 'code')
expect(id).toEqual('abcd')
})
})
})
})

class AccessTokenError extends Error {}

0 comments on commit b4cebbf

Please sign in to comment.