Files
ui/test/components/Avatar.spec.ts
Sandro Circi 104852a55c chore: use new syntax for css variables (#3258)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2025-02-07 11:24:14 +01:00

26 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import Avatar, { type AvatarProps, type AvatarSlots } from '../../src/runtime/components/Avatar.vue'
import ComponentRender from '../component-render'
import theme from '#build/ui/avatar'
describe('Avatar', () => {
const sizes = Object.keys(theme.variants.size) as any
it.each([
// Props
['with src', { props: { src: 'https://github.com/benjamincanac.png' } }],
['with alt', { props: { alt: 'Benjamin Canac' } }],
['with text', { props: { text: '+1' } }],
['with icon', { props: { icon: 'i-lucide-image' } }],
...sizes.map((size: string) => [`with size ${size}`, { props: { src: 'https://github.com/benjamincanac.png', size } }]),
['with as', { props: { as: 'section' } }],
['with class', { props: { class: 'bg-(--ui-bg)' } }],
['with ui', { props: { ui: { fallback: 'font-bold' } } }],
// Slots
['with default slot', { slots: { default: '🇫🇷' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: AvatarProps, slots?: AvatarSlots }) => {
const html = await ComponentRender(nameOrHtml, options, Avatar)
expect(html).toMatchSnapshot()
})
})