Created
September 7, 2018 19:55
-
-
Save kuroski/58ec03b63f478643e7768c2323619fde to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { shallowMount, createLocalVue } from '@vue/test-utils' | |
import Vuex from 'vuex' | |
import UserView from '@/views/UserView' | |
import VUserSearchForm from '@/components/VUserSearchForm' | |
import VUserProfile from '@/components/VUserProfile' | |
import initialState from '@/store/state' | |
import userFixture from './fixtures/user' | |
const localVue = createLocalVue() | |
localVue.use(Vuex) | |
describe('UserView', () => { | |
let state | |
const build = () => { | |
const wrapper = shallowMount(UserView, { | |
localVue, | |
store: new Vuex.Store({ state }) | |
}) | |
return { | |
wrapper, | |
userSearchForm: () => wrapper.find(VUserSearchForm), | |
userProfile: () => wrapper.find(VUserProfile) | |
} | |
} | |
beforeEach(() => { | |
state = { ...initialState } | |
}) | |
... | |
... | |
it('passes a binded user prop to user profile component', () => { | |
// arrange | |
state.user = userFixture | |
const { userProfile } = build() | |
// assert | |
expect(userProfile().vm.user).toBe(state.user) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment