✅ test: added test file
This commit is contained in:
parent
e05b10a34b
commit
83f9097970
37
test/VMessage.spec.ts
Normal file
37
test/VMessage.spec.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { describe, it, expect } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import VMessage from '../src/components/message/VMessage.vue'
|
||||
|
||||
describe('VMessage.vue', () => {
|
||||
it('renders the title', () => {
|
||||
const wrapper = mount(VMessage, {
|
||||
props: { title: 'Test Message' }
|
||||
})
|
||||
expect(wrapper.text()).toContain('Test Message')
|
||||
})
|
||||
|
||||
it('shows the correct icon class for type "alert"', () => {
|
||||
const wrapper = mount(VMessage, {
|
||||
props: { title: 'Alert Message', type: 'alert' }
|
||||
})
|
||||
const icon = wrapper.find('i')
|
||||
expect(icon.classes()).toContain('ri-spam-fill')
|
||||
})
|
||||
|
||||
it('shows the close button if closable is true', () => {
|
||||
const wrapper = mount(VMessage, {
|
||||
props: { title: 'Closable Message', closable: true }
|
||||
})
|
||||
const button = wrapper.find('button[aria-label="Fermer"]')
|
||||
expect(button.exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('emits close event when close button is clicked', async () => {
|
||||
const wrapper = mount(VMessage, {
|
||||
props: { title: 'Closable Message', closable: true }
|
||||
})
|
||||
const button = wrapper.find('button[aria-label="Fermer"]')
|
||||
await button.trigger('click')
|
||||
expect(wrapper.emitted()).toHaveProperty('close')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user