Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #812 from h3poteto/iss-209
refs #209 Add Authorize store tests
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} |