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>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import Collapsible from '../../src/runtime/components/Collapsible.vue'
|
|
import type { CollapsibleProps, CollapsibleSlots } from '../../src/runtime/components/Collapsible.vue'
|
|
import ComponentRender from '../component-render'
|
|
|
|
describe('Collapsible', () => {
|
|
const props = { open: true }
|
|
|
|
it.each([
|
|
// Props
|
|
['with open', { props }],
|
|
['with as', { props: { ...props, as: 'section' } }],
|
|
['with unmountOnHide', { props: { ...props, unmountOnHide: false } }],
|
|
['with disabled', { props: { ...props, disabled: true } }],
|
|
['with class', { props: { ...props, class: 'flex flex-col gap-2 w-48' } }],
|
|
['with ui', { props: { ...props, ui: { content: 'bg-elevated' } } }],
|
|
// Slots
|
|
['with default slot', { props, slots: { default: () => 'Default slot' } }],
|
|
['with content slot', { props, slots: { content: () => 'Content slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: CollapsibleProps, slots?: Partial<CollapsibleSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, Collapsible)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(Collapsible, {
|
|
props: {
|
|
open: true
|
|
}
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|