-
Notifications
You must be signed in to change notification settings - Fork 686
/
Copy pathAvatar.spec.ts
25 lines (23 loc) · 1.15 KB
/
Avatar.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
})
})