Skip to content
Snippets Groups Projects
Commit f5cab3bd authored by Eline Evje's avatar Eline Evje
Browse files

test: made unit tests for ContinueButtonComponent

parent ddf9f624
No related branches found
No related tags found
3 merge requests!66Final merge,!14Enhancement/implement more config steps,!4Pipeline fix
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import ContinueButtonComponent from '@/components/ContinueButtonComponent.vue'
describe('ContinueButtonComponent', () => {
it('renders correctly', () => {
const wrapper = mount(ContinueButtonComponent)
expect(wrapper.text()).toContain('Fortsett')
})
it('is disabled when the `disabled` prop is true', () => {
const wrapper = mount(ContinueButtonComponent, {
props: { disabled: true }
})
const button = wrapper.find('button')
expect(button.attributes('disabled')).toBeDefined()
expect(button.classes()).toContain('opacity-60')
expect(button.classes()).toContain('cursor-not-allowed')
})
it('does not emit click event when disabled', async () => {
const wrapper = mount(ContinueButtonComponent, {
props: { disabled: true }
})
await wrapper.trigger('click')
expect(wrapper.emitted()).not.toHaveProperty('click')
})
it('emits click event when not disabled', async () => {
const wrapper = mount(ContinueButtonComponent, {
props: { disabled: false }
})
await wrapper.trigger('click')
expect(wrapper.emitted()).toHaveProperty('click')
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment