Files
nuxt__ui/test/components/DashboardSearchButton.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

33 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { axe } from 'vitest-axe'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import DashboardSearchButton from '../../src/runtime/components/DashboardSearchButton.vue'
import type { DashboardSearchButtonProps } from '../../src/runtime/components/DashboardSearchButton.vue'
import ComponentRender from '../component-render'
describe('DashboardSearchButton', () => {
it.each([
// Props
['with label', { props: { label: 'Open' } }],
['with icon', { props: { icon: 'i-lucide-house' } }],
['with kbds', { props: { kbds: ['alt', 'o'] } }],
['with collapsed', { props: { collapsed: true } }],
['with class', { props: { class: 'w-full' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: DashboardSearchButtonProps }) => {
const html = await ComponentRender(nameOrHtml, options, DashboardSearchButton)
expect(html).toMatchSnapshot()
})
it('passes accessibility tests', async () => {
const wrapper = await mountSuspended(DashboardSearchButton, {
props: {
label: 'Open',
icon: 'i-lucide-house',
kbds: ['alt', 'o']
}
})
expect(await axe(wrapper.element)).toHaveNoViolations()
})
})