File size: 970 Bytes
21277d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import ButtonComponent from '@/components/buttons/ButtonComponent.vue'
describe('ButtonComponent', () => {
it('renders slot content', () => {
const wrapper = mount(ButtonComponent, {
props: { click: () => {} },
slots: { default: 'Click me' },
})
expect(wrapper.find('button').text()).toBe('Click me')
})
it('calls click prop on click', async () => {
const clickFn = vi.fn()
const wrapper = mount(ButtonComponent, {
props: { click: clickFn },
slots: { default: 'Click me' },
})
await wrapper.find('button').trigger('click')
expect(clickFn).toHaveBeenCalledOnce()
})
it('renders HTML slot content', () => {
const wrapper = mount(ButtonComponent, {
props: { click: () => {} },
slots: { default: '<span>icon</span> Save' },
})
expect(wrapper.find('button span').text()).toBe('icon')
})
})
|