-
Notifications
You must be signed in to change notification settings - Fork 687
/
Copy pathCarousel.spec.ts
44 lines (40 loc) · 1.92 KB
/
Carousel.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
37
38
39
40
41
42
43
44
import { defineComponent } from 'vue'
import { describe, it, expect } from 'vitest'
import Carousel, { type CarouselProps, type CarouselSlots } from '../../src/runtime/components/Carousel.vue'
import ComponentRender from '../component-render'
const CarouselWrapper = defineComponent({
components: {
UCarousel: Carousel as any
},
template: `<UCarousel v-slot="{ item }">
<img :src="item.src" width="300" height="300" class="rounded-lg">
</UCarousel>`
})
describe('Carousel', () => {
const items = [
{ src: 'https://picsum.photos/600/600?random=1' },
{ src: 'https://picsum.photos/600/600?random=2' },
{ src: 'https://picsum.photos/600/600?random=3' },
{ src: 'https://picsum.photos/600/600?random=4' },
{ src: 'https://picsum.photos/600/600?random=5' },
{ src: 'https://picsum.photos/600/600?random=6' }
]
const props = { items }
it.each([
// Props
['with items', { props }],
['with orientation vertical', { props: { ...props, orientation: 'vertical' as const } }],
['with arrows', { props: { ...props, arrows: true } }],
['with prev', { props: { ...props, arrows: true, prev: { color: 'primary' as const } } }],
['with prevIcon', { props: { ...props, arrows: true, prevIcon: 'i-lucide-arrow-left' } }],
['with next', { props: { ...props, arrows: true, next: { color: 'primary' as const } } }],
['with nextIcon', { props: { ...props, arrows: true, nextIcon: 'i-lucide-arrow-right' } }],
['with dots', { props: { ...props, dots: true } }],
['with as', { props: { ...props, as: 'nav' } }],
['with class', { props: { ...props, class: 'w-full max-w-xs' } }],
['with ui', { props: { ...props, ui: { viewport: 'h-[320px]' } } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: CarouselProps, slots?: Partial<CarouselSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, CarouselWrapper)
expect(html).toMatchSnapshot()
})
})