Skip to content

Instantly share code, notes, and snippets.

@lex111
Forked from eddyerburgh/MessageToggle.spec.js
Last active July 1, 2018 12:37
Show Gist options
  • Save lex111/c941675d90b101d26126a829554a98f5 to your computer and use it in GitHub Desktop.
Save lex111/c941675d90b101d26126a829554a98f5 to your computer and use it in GitHub Desktop.
import { mount } from '@vue/test-utils'
import MessageToggle from '@/components/MessageToggle.vue'
describe('MessageToggle.vue', () => {
it('displays default message', () => {
const wrapper = mount(MessageToggle)
expect(wrapper.text()).toContain('default message')
})
it('toggles message when button is clicked', () => {
const wrapper = mount(MessageToggle)
const button = wrapper.find('#toggle-message')
const p = wrapper.find('p')
button.trigger('click')
expect(p.text()).toBe('message')
button.trigger('click')
expect(p.text()).toBe('toggled message')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment