feat(Breadcrumb): new component

Resolves #22
This commit is contained in:
Benjamin Canac
2024-04-16 17:23:41 +02:00
parent 298ac68447
commit 53a2bc0264
8 changed files with 237 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { describe, it, expect } from 'vitest'
import Breadcrumb, { type BreadcrumbProps } from '../../src/runtime/components/Breadcrumb.vue'
import ComponentRender from '../component-render'
describe('Breadcrumb', () => {
const links = [{
label: 'Home',
avatar: {
src: 'https://avatars.githubusercontent.com/u/739984?v=4'
},
to: '/'
}, {
label: 'Navigation',
icon: 'i-heroicons-square-3-stack-3d',
disabled: true
}, {
label: 'Breadcrumb',
icon: 'i-heroicons-link'
}]
it.each([
// Props
['with links', { props: { links } }],
['with separatorIcon', { props: { links, separatorIcon: 'i-heroicons-minus' } }],
['with class', { props: { class: 'w-48' } }],
['with ui', { props: { ui: { link: 'font-bold' } } }],
// Slots
['with default slot', { slots: { default: () => 'Default slot' } }],
['with leading slot', { slots: { leading: () => 'Leading slot' } }],
['with trailing slot', { slots: { trailing: () => 'Trailing slot' } }],
['with separator slot', { slots: { separator: () => '/' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: BreadcrumbProps<typeof links[number]>, slots?: any }) => {
const html = await ComponentRender(nameOrHtml, options, Breadcrumb)
expect(html).toMatchSnapshot()
})
})