Skip to content

Instantly share code, notes, and snippets.

@kuroski
Created September 7, 2018 19:18
Show Gist options
  • Save kuroski/9384336e96f38b1cf6cf3465d1163c6a to your computer and use it in GitHub Desktop.
Save kuroski/9384336e96f38b1cf6cf3465d1163c6a 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)
return {
wrapper,
userSearchForm: () => wrapper.find(VUserSearchForm),
userProfile: () => wrapper.find(VUserProfile)
}
}
it('renders the component', () => {
// arrange
const { wrapper } = build()
// assert
expect(wrapper.html()).toMatchSnapshot()
})
it('renders main child components', () => {
// arrange
const { userSearchForm, userProfile } = build()
// assert
expect(userSearchForm().exists()).toBe(true)
expect(userProfile().exists()).toBe(true)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment