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>
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import type { LinkProps, LinkSlots } from '../../src/runtime/components/Link.vue'
|
|
import ComponentRender from '../component-render'
|
|
import { ULink as Link } from '#components'
|
|
|
|
describe('Link', () => {
|
|
it.each([
|
|
// Props
|
|
['with as', { props: { as: 'div' } }],
|
|
['with to', { props: { to: '/' } }],
|
|
['with type', { props: { type: 'submit' as const } }],
|
|
['with disabled', { props: { disabled: true } }],
|
|
['with activeClass', { props: { active: true, activeClass: 'text-highlighted' } }],
|
|
['with inactiveClass', { props: { active: false, inactiveClass: 'hover:text-primary' } }],
|
|
['with raw', { props: { raw: true } }],
|
|
['with raw activeClass', { props: { raw: true, active: true, activeClass: 'text-highlighted' } }],
|
|
['with raw inactiveClass', { props: { raw: true, active: false, inactiveClass: 'hover:text-primary' } }],
|
|
['with class', { props: { class: 'font-medium' } }],
|
|
// Slots
|
|
['with default slot', { slots: { default: () => 'Default slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: LinkProps, slots?: Partial<LinkSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, Link)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(Link, {
|
|
props: {
|
|
to: '/'
|
|
},
|
|
slots: {
|
|
default: () => 'Home'
|
|
}
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|