mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
955dac1ad1
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import { renderEach } from '../component-render'
|
|
import Breadcrumb from '../../src/runtime/components/Breadcrumb.vue'
|
|
|
|
describe('Breadcrumb', () => {
|
|
const items = [{
|
|
label: 'Home',
|
|
avatar: {
|
|
src: 'https://github.com/benjamincanac.png',
|
|
alt: 'Benjamin Canac'
|
|
},
|
|
to: '/'
|
|
}, {
|
|
label: 'Components',
|
|
icon: 'i-lucide-box',
|
|
disabled: true
|
|
}, {
|
|
label: 'Breadcrumb',
|
|
to: '/components/breadcrumb',
|
|
icon: 'i-lucide-link',
|
|
slot: 'custom' as const
|
|
}]
|
|
|
|
const props = { items }
|
|
|
|
renderEach(Breadcrumb<typeof items[number]>, [
|
|
// Props
|
|
['with items', { props }],
|
|
['with labelKey', { props: { ...props, labelKey: 'icon' } }],
|
|
['with separatorIcon', { props: { ...props, separatorIcon: 'i-lucide-minus' } }],
|
|
['with color neutral', { props: { ...props, color: 'neutral' } }],
|
|
['with as', { props: { ...props, as: 'div' } }],
|
|
['with class', { props: { ...props, class: 'w-48' } }],
|
|
['with ui', { props: { ...props, ui: { link: 'font-bold' } } }],
|
|
// Slots
|
|
['with item slot', { props, slots: { item: () => 'Item slot' } }],
|
|
['with item-leading slot', { props, slots: { 'item-leading': () => 'Item leading slot' } }],
|
|
['with item-label slot', { props, slots: { 'item-label': () => 'Item label slot' } }],
|
|
['with item-trailing slot', { props, slots: { 'item-trailing': () => 'Item trailing slot' } }],
|
|
['with custom slot', { props, slots: { custom: () => 'Custom slot' } }],
|
|
['with separator slot', { props, slots: { separator: () => '/' } }]
|
|
])
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(Breadcrumb, {
|
|
props
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|