mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(Card): new component
This commit is contained in:
15
test/components/Card.spec.ts
Normal file
15
test/components/Card.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import Card, { type CardProps } from '../../src/runtime/components/Card.vue'
|
||||
import ComponentRender from '../component-render'
|
||||
|
||||
describe('Card', () => {
|
||||
it.each([
|
||||
['basic case', {}],
|
||||
['with default slot', { slots: { default: () => 'Default slot' } }],
|
||||
['with header slot', { slots: { header: () => 'Header slot' } }],
|
||||
['with footer slot', { slots: { footer: () => 'Footer slot' } }]
|
||||
])('renders %s correctly', async (nameOrHtml: string, options: { props?: CardProps, slots?: any }) => {
|
||||
const html = await ComponentRender(nameOrHtml, options, Card)
|
||||
expect(html).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
33
test/components/__snapshots__/Card.spec.ts.snap
Normal file
33
test/components/__snapshots__/Card.spec.ts.snap
Normal file
@@ -0,0 +1,33 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Card > renders basic case correctly 1`] = `
|
||||
"<div class="bg-white dark:bg-gray-900 ring ring-gray-200 dark:ring-gray-800 rounded-lg shadow">
|
||||
<!--v-if-->
|
||||
<!--v-if-->
|
||||
<!--v-if-->
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Card > renders with default slot correctly 1`] = `
|
||||
"<div class="bg-white dark:bg-gray-900 ring ring-gray-200 dark:ring-gray-800 rounded-lg shadow">
|
||||
<!--v-if-->
|
||||
<div class="px-4 py-5 sm:p-6">Default slot</div>
|
||||
<!--v-if-->
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Card > renders with footer slot correctly 1`] = `
|
||||
"<div class="bg-white dark:bg-gray-900 ring ring-gray-200 dark:ring-gray-800 rounded-lg shadow">
|
||||
<!--v-if-->
|
||||
<!--v-if-->
|
||||
<div class="p-4 sm:px-6">Footer slot</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Card > renders with header slot correctly 1`] = `
|
||||
"<div class="bg-white dark:bg-gray-900 ring ring-gray-200 dark:ring-gray-800 rounded-lg shadow">
|
||||
<div class="p-4 sm:px-6">Header slot</div>
|
||||
<!--v-if-->
|
||||
<!--v-if-->
|
||||
</div>"
|
||||
`;
|
||||
Reference in New Issue
Block a user