Files
nuxt__ui/test/components/PageAside.spec.ts
Jakub Michálek f2d73e5bee test(components): add a11y tests (#5181)
Co-authored-by: Jakub <jakub.michalek@freelo.io>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2025-10-14 13:56:06 +02:00

35 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { axe } from 'vitest-axe'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import PageAside from '../../src/runtime/components/PageAside.vue'
import type { PageAsideProps, PageAsideSlots } from '../../src/runtime/components/PageAside.vue'
import ComponentRender from '../component-render'
describe('PageAside', () => {
it.each([
// Props
['with as', { props: { as: 'div' } }],
['with class', { props: { class: 'lg:flex' } }],
['with ui', { props: { ui: { container: 'absolute' } } }],
// Slots
['with top slot', { slots: { top: () => 'Top slot' } }],
['with default slot', { slots: { default: () => 'Default slot' } }],
['with bottom slot', { slots: { bottom: () => 'Bottom slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: PageAsideProps, slots?: Partial<PageAsideSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, PageAside)
expect(html).toMatchSnapshot()
})
it('passes accessibility tests', async () => {
const wrapper = await mountSuspended(PageAside, {
slots: {
top: () => 'Top slot',
default: () => 'Default slot',
bottom: () => 'Bottom slot'
}
})
expect(await axe(wrapper.element)).toHaveNoViolations()
})
})