Last active
September 8, 2018 21:12
-
-
Save kuroski/2d3708e09f0ab6fdd24a6e2450e9a70b to your computer and use it in GitHub Desktop.
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
jest.mock('@/api') | |
import flushPromises from 'flush-promises' | |
import actions from '@/store/actions' | |
import api from '@/api' | |
import userFixture from './fixtures/user' | |
describe('store actions', () => { | |
let commit | |
beforeEach(() => { | |
commit = jest.fn() | |
}) | |
it('searches for user', async () => { | |
// arrange | |
const expectedUser = 'kuroski' | |
// act | |
await actions.SEARCH_USER({ commit }, { username: expectedUser }) | |
await flushPromises() | |
// assert | |
expect(api.searchUser).toHaveBeenCalledWith(expectedUser) | |
expect(commit).toHaveBeenCalledWith('SET_USER', userFixture) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment