import { describe, it, expect } from 'vitest' import { h } from 'vue' import { mount } from '@vue/test-utils' import { Alert, AlertTitle, AlertDescription } from '../src/lib' describe('Alert', () => { it('defaults to the info variant', () => { const wrapper = mount(Alert) expect(wrapper.classes().join(' ')).toContain('bg-info/15') }) it('applies the danger variant class', () => { const wrapper = mount(Alert, { props: { variant: 'danger' } }) expect(wrapper.classes().join(' ')).toContain('bg-destructive/15') }) it('renders title and description slots', () => { const wrapper = mount(Alert, { slots: { default: () => [ h(AlertTitle, undefined, { default: () => 'The Oracle has spoken.' }), h(AlertDescription, undefined, { default: () => 'Heed the omen.' }), ], }, }) expect(wrapper.text()).toContain('The Oracle has spoken.') expect(wrapper.text()).toContain('Heed the omen.') }) it('does not render a close button unless closable is set', () => { const wrapper = mount(Alert) expect(wrapper.find('button').exists()).toBe(false) }) it('emits close when the close button is clicked', async () => { const wrapper = mount(Alert, { props: { closable: true } }) await wrapper.find('button').trigger('click') expect(wrapper.emitted('close')).toHaveLength(1) }) })