Skip to content

Instantly share code, notes, and snippets.

@kuroski
Created September 7, 2018 19:35
Show Gist options
  • Save kuroski/03a62e70b0e0bf2a6c2973a44c2e5016 to your computer and use it in GitHub Desktop.
Save kuroski/03a62e70b0e0bf2a6c2973a44c2e5016 to your computer and use it in GitHub Desktop.
import { shallowMount } from '@vue/test-utils'
import UserView from '@/views/UserView'
import VUserSearchForm from '@/components/VUserSearchForm'
import VUserProfile from '@/components/VUserProfile'
describe('UserView', () => {
const build = () => {
const wrapper = shallowMount(UserView, {
data: () => ({
user: {}
})
})
return {
wrapper,
userSearchForm: () => wrapper.find(VUserSearchForm),
userProfile: () => wrapper.find(VUserProfile)
}
}
...
...
it('passes a binded user prop to user profile component', () => {
// arrange
const { wrapper, userProfile } = build()
wrapper.setData({
user: {
name: 'Daniel'
}
})
// assert
expect(userProfile().vm.user).toBe(wrapper.vm.user)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment