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>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import Chip from '../../src/runtime/components/Chip.vue'
|
|
import type { ChipProps, ChipSlots } from '../../src/runtime/components/Chip.vue'
|
|
import ComponentRender from '../component-render'
|
|
import theme from '#build/ui/chip'
|
|
|
|
describe('Chip', () => {
|
|
const sizes = Object.keys(theme.variants.size) as any
|
|
const positions = Object.keys(theme.variants.position) as any
|
|
|
|
it.each([
|
|
// Props
|
|
['with text', { props: { text: 'Text' } }],
|
|
['with inset', { props: { inset: true } }],
|
|
...sizes.map((size: string) => [`with size ${size}`, { props: { size } }]),
|
|
...positions.map((position: string) => [`with position ${position}`, { props: { position } }]),
|
|
['with color neutral', { props: { color: 'neutral' } }],
|
|
['without show', { props: { show: false } }],
|
|
['with as', { props: { as: 'span' } }],
|
|
['with class', { props: { class: 'mx-auto' } }],
|
|
['with ui', { props: { ui: { base: 'text-muted' } } }],
|
|
// Slots
|
|
['with default slot', { slots: { default: () => 'Default slot' } }],
|
|
['with content slot', { slots: { content: () => 'Content slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ChipProps, slots?: Partial<ChipSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, Chip)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(Chip, {
|
|
props: {
|
|
text: 'Text'
|
|
}
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|