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>
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import Kbd from '../../src/runtime/components/Kbd.vue'
|
|
import type { KbdProps, KbdSlots } from '../../src/runtime/components/Kbd.vue'
|
|
import ComponentRender from '../component-render'
|
|
import theme from '#build/ui/kbd'
|
|
|
|
describe('Kbd', () => {
|
|
const sizes = Object.keys(theme.variants.size) as any
|
|
const variants = Object.keys(theme.variants.variant) as any
|
|
|
|
it.each([
|
|
// Props
|
|
['with value', { props: { value: 'K' } }],
|
|
...sizes.map((size: string) => [`with size ${size}`, { props: { value: 'K', size } }]),
|
|
...variants.map((variant: string) => [`with primary variant ${variant}`, { props: { value: 'K', variant } }]),
|
|
...variants.map((variant: string) => [`with neutral variant ${variant}`, { props: { value: 'K', variant, color: 'neutral' } }]),
|
|
['with as', { props: { value: 'K', as: 'span' } }],
|
|
['with class', { props: { value: 'K', class: 'font-bold' } }],
|
|
// Slots
|
|
['with default slot', { slots: { default: () => 'Default slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: KbdProps, slots?: Partial<KbdSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, Kbd)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(Kbd, {
|
|
props: {
|
|
value: 'K'
|
|
}
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|