chore(Container): add component

This commit is contained in:
Benjamin Canac
2024-03-06 16:03:45 +01:00
parent d95556ebda
commit 5449d2aa5f
4 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import { describe, it, expect } from 'vitest'
import Container, { type ContainerProps } from '../../src/runtime/components/Container.vue'
import ComponentRender from '../component-render'
describe('Container', () => {
it.each([
['basic case', {}],
['with as', { props: { as: 'article' } }],
['with class', { props: { class: 'max-w-5xl' } }],
['with default slot', { slots: { default: () => 'Default slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ContainerProps, slots?: any }) => {
const html = await ComponentRender(nameOrHtml, options, Container)
expect(html).toMatchSnapshot()
})
})

View File

@@ -0,0 +1,9 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`Container > renders basic case correctly 1`] = `"<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"></div>"`;
exports[`Container > renders with as correctly 1`] = `"<article class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"></article>"`;
exports[`Container > renders with class correctly 1`] = `"<div class="mx-auto px-4 sm:px-6 lg:px-8 max-w-5xl"></div>"`;
exports[`Container > renders with default slot correctly 1`] = `"<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">Default slot</div>"`;