mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
import { shallowMount } from '@vue/test-utils'
|
|
import Alert from '@baserow/modules/core/components/Alert'
|
|
|
|
describe('Alert.vue', () => {
|
|
it('renders the alert title and message', () => {
|
|
const title = 'This is an alert title.'
|
|
const message = 'This is an alert message.'
|
|
const wrapper = shallowMount(Alert, {
|
|
slots: {
|
|
title,
|
|
default: message,
|
|
},
|
|
})
|
|
expect(wrapper.find('.alert__title').text()).toMatch('title')
|
|
expect(wrapper.find('.alert__message').text()).toMatch(message)
|
|
})
|
|
|
|
it('emits the close event when the close button is clicked', () => {
|
|
const closeButton = true
|
|
const wrapper = shallowMount(Alert, {
|
|
propsData: { closeButton },
|
|
})
|
|
wrapper.find('.alert__close').trigger('click')
|
|
expect(wrapper.emitted().close).toBeTruthy()
|
|
})
|
|
|
|
it('sets the alert type based on the type prop', () => {
|
|
const type = 'success'
|
|
const wrapper = shallowMount(Alert, {
|
|
propsData: { type },
|
|
})
|
|
expect(wrapper.classes()).toContain(`alert--${type}`)
|
|
})
|
|
})
|