-
Notifications
You must be signed in to change notification settings - Fork 697
/
Copy pathAvatarGroup.spec.ts
36 lines (33 loc) · 1.41 KB
/
AvatarGroup.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
26
27
28
29
30
31
32
33
34
35
36
import { defineComponent } from 'vue'
import { describe, it, expect } from 'vitest'
import Avatar from '../../src/runtime/components/Avatar.vue'
import AvatarGroup, { type AvatarGroupProps, type AvatarGroupSlots } from '../../src/runtime/components/AvatarGroup.vue'
import ComponentRender from '../component-render'
import theme from '#build/ui/avatar-group'
const AvatarGroupWrapper = defineComponent({
components: {
UAvatar: Avatar,
UAvatarGroup: AvatarGroup
},
template: `<UAvatarGroup>
<UAvatar src="https://github.com/benjamincanac.png" alt="Benjamin Canac" />
<UAvatar src="https://github.com/romhml.png" alt="Romain Hamel" />
<UAvatar src="https://github.com/noook.png" alt="Neil Richter" />
</UAvatarGroup>`
})
describe('AvatarGroup', () => {
const sizes = Object.keys(theme.variants.size) as any
it.each([
// Props
['with max', { props: { max: 2 } }],
...sizes.map((size: string) => [`with size ${size}`, { props: { size } }]),
['with as', { props: { as: 'span' } }],
['with class', { props: { class: 'justify-start' } }],
['with ui', { props: { ui: { base: 'rounded-lg' } } }],
// Slots
['with default slot', {}]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: AvatarGroupProps, slots?: Partial<AvatarGroupSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, AvatarGroupWrapper)
expect(html).toMatchSnapshot()
})
})