Last active
October 25, 2018 22:00
-
-
Save kuroski/6ef9b697bb7969022cf70afe7969d89c 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
import { shallowMount } from '@vue/test-utils' | |
import VUserProfile from '@/components/VUserProfile' | |
import user from './fixtures/user' | |
describe('VUserProfile', () => { | |
let props | |
const build = () => { | |
const wrapper = shallowMount(VUserProfile, { | |
propsData: props, | |
}) | |
return { | |
wrapper, | |
avatar: () => wrapper.find('.user-profile__avatar'), | |
name: () => wrapper.find('.user-profile__name'), | |
bio: () => wrapper.find('.user-profile__bio'), | |
} | |
} | |
beforeEach(() => { | |
props = { | |
user | |
} | |
}) | |
it('renders the component', () => { | |
// arrange | |
const { wrapper } = build() | |
// assert | |
expect(wrapper.html()).toMatchSnapshot() | |
}) | |
it('renders main components', () => { | |
// arrange | |
const { avatar, name, bio } = build() | |
// assert | |
expect(avatar().exists()).toBe(true) | |
expect(avatar().attributes().src).toBe(props.user.avatar_url) | |
expect(name().exists()).toBe(true) | |
expect(name().text()).toBe(props.user.name) | |
expect(bio().exists()).toBe(true) | |
expect(bio().text()).toBe(props.user.bio) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment