mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
f2d73e5bee
Co-authored-by: Jakub <jakub.michalek@freelo.io> Co-authored-by: Benjamin Canac <canacb1@gmail.com>
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import ChatPrompt from '../../src/runtime/components/ChatPrompt.vue'
|
|
import type { ChatPromptProps, ChatPromptSlots } from '../../src/runtime/components/ChatPrompt.vue'
|
|
import ComponentRender from '../component-render'
|
|
import theme from '#build/ui/chat-prompt'
|
|
|
|
describe('ChatPrompt', () => {
|
|
const variants = Object.keys(theme.variants.variant) as any
|
|
|
|
it.each([
|
|
// Props
|
|
['with placeholder', { props: { placeholder: 'Placeholder' } }],
|
|
['with error', { props: { error: new Error('Error') } }],
|
|
...variants.map((variant: string) => [`with variant ${variant}`, { props: { variant } }]),
|
|
['with as', { props: { as: 'section' } }],
|
|
['with class', { props: { class: 'p-5' } }],
|
|
['with ui', { props: { ui: { footer: 'justify-end' } } }],
|
|
// Slots
|
|
['with header slot', { slots: { header: () => 'Header slot' } }],
|
|
['with footer slot', { slots: { footer: () => 'Footer slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ChatPromptProps, slots?: Partial<ChatPromptSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, ChatPrompt)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(ChatPrompt, {
|
|
props: {
|
|
placeholder: 'Placeholder'
|
|
}
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|