mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
36
test/components/Breadcrumb.spec.ts
Normal file
36
test/components/Breadcrumb.spec.ts
Normal 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()
|
||||
})
|
||||
})
|
||||
71
test/components/__snapshots__/Breadcrumb.spec.ts.snap
Normal file
71
test/components/__snapshots__/Breadcrumb.spec.ts.snap
Normal file
@@ -0,0 +1,71 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Breadcrumb > renders with class correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0 w-48">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with default slot correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with leading slot correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with links correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5">
|
||||
<li class="flex min-w-0"><a href="/" class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"><span class="inline-flex items-center justify-center select-none overflow-hidden rounded-full align-middle bg-gray-100 dark:bg-gray-800 size-5 text-[10px] shrink-0"><img role="img" src="https://avatars.githubusercontent.com/u/739984?v=4" class="h-full w-full rounded-[inherit] object-cover" style="display: none;"><span class="font-medium leading-none text-gray-500 dark:text-gray-400 truncate"></span></span><span class="truncate">Home</span></a></li>
|
||||
<li role="presentation" class="flex"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5 text-gray-500 dark:text-gray-400" width="1em" height="1em" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" fill-rule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10L8.22 6.28a.75.75 0 0 1 0-1.06" clip-rule="evenodd"></path>
|
||||
</svg></li>
|
||||
<li class="flex min-w-0"><span class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-not-allowed opacity-75"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6.429 9.75L2.25 12l4.179 2.25m0-4.5l5.571 3l5.571-3m-11.142 0L2.25 7.5L12 2.25l9.75 5.25l-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0l4.179 2.25L12 21.75L2.25 16.5l4.179-2.25m11.142 0l-5.571 3l-5.571-3"></path></svg><span class="truncate">Navigation</span></span></li>
|
||||
<li role="presentation" class="flex"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5 text-gray-500 dark:text-gray-400" width="1em" height="1em" viewBox="0 0 20 20">
|
||||
<path fill="currentColor" fill-rule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10L8.22 6.28a.75.75 0 0 1 0-1.06" clip-rule="evenodd"></path>
|
||||
</svg></li>
|
||||
<li class="flex min-w-0"><span aria-current="page" class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-primary-500 dark:text-primary-400"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"></path></svg><span class="truncate">Breadcrumb</span></span></li>
|
||||
<!--v-if-->
|
||||
</ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with separator slot correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with separatorIcon correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5">
|
||||
<li class="flex min-w-0"><a href="/" class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"><span class="inline-flex items-center justify-center select-none overflow-hidden rounded-full align-middle bg-gray-100 dark:bg-gray-800 size-5 text-[10px] shrink-0"><img role="img" src="https://avatars.githubusercontent.com/u/739984?v=4" class="h-full w-full rounded-[inherit] object-cover" style="display: none;"><span class="font-medium leading-none text-gray-500 dark:text-gray-400 truncate"></span></span><span class="truncate">Home</span></a></li>
|
||||
<li role="presentation" class="flex"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5 text-gray-500 dark:text-gray-400" width="1em" height="1em" viewBox="0 0 24 24">
|
||||
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5 12h14"></path>
|
||||
</svg></li>
|
||||
<li class="flex min-w-0"><span class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white cursor-not-allowed opacity-75"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6.429 9.75L2.25 12l4.179 2.25m0-4.5l5.571 3l5.571-3m-11.142 0L2.25 7.5L12 2.25l9.75 5.25l-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0l4.179 2.25L12 21.75L2.25 16.5l4.179-2.25m11.142 0l-5.571 3l-5.571-3"></path></svg><span class="truncate">Navigation</span></span></li>
|
||||
<li role="presentation" class="flex"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5 text-gray-500 dark:text-gray-400" width="1em" height="1em" viewBox="0 0 24 24">
|
||||
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5 12h14"></path>
|
||||
</svg></li>
|
||||
<li class="flex min-w-0"><span aria-current="page" class="group relative flex items-center gap-1.5 font-medium text-sm min-w-0 text-primary-500 dark:text-primary-400"><svg data-v-9533427c="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="icon shrink-0 size-5" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"></path></svg><span class="truncate">Breadcrumb</span></span></li>
|
||||
<!--v-if-->
|
||||
</ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with trailing slot correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Breadcrumb > renders with ui correctly 1`] = `
|
||||
"<div aria-label="breadcrumb" class="relative min-w-0">
|
||||
<ol class="flex items-center gap-1.5"></ol>
|
||||
</div>"
|
||||
`;
|
||||
Reference in New Issue
Block a user