Skip to content

Instantly share code, notes, and snippets.

@lex111
Forked from eddyerburgh/List.spec.js
Created July 1, 2018 12:53
Show Gist options
  • Save lex111/ac60c7e2dbd87db214f0dc74f6172577 to your computer and use it in GitHub Desktop.
Save lex111/ac60c7e2dbd87db214f0dc74f6172577 to your computer and use it in GitHub Desktop.
import { shallowMount } from '@vue/test-utils'
import { createRenderer } from 'vue-server-renderer'
import List from '@/components/List.vue'
describe('List.vue', () => {
it('renders li for each item in props.items', () => {
const items = ['', '']
const wrapper = shallowMount(List, {
propsData: { items }
})
expect(wrapper.findAll('li')).toHaveLength(items.length)
})
it('has same HTML structure', () => {
const items = ['item one', 'item two']
const renderer = createRenderer()
const wrapper = shallowMount(List, { propsData: { items } })
renderer.renderToString(wrapper.vm, (err, str) => {
if (err) throw new Error(err)
expect(str).toMatchSnapshot()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment