Files
Benjamin Canac 5cb65cfbd0 feat: import @nuxt/ui-pro components (#4675)
Co-authored-by: Hugo Richard <hugo.richard@epitech.eu>
2025-09-01 14:30:39 +02:00

34 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import Error from '../../src/runtime/components/Error.vue'
import type { ErrorProps, ErrorSlots } from '../../src/runtime/components/Error.vue'
import ComponentRender from '../component-render'
describe('Error', () => {
const error = {
statusCode: 404,
statusMessage: 'Not Found',
message: 'The page you are looking for does not exist.'
}
const props = { error }
it.each([
// Props
['with error', { props }],
['with redirect', { props: { ...props, redirect: '/blog' } }],
['with clear', { props: { ...props, clear: { label: 'Home' } } }],
['with as', { props: { ...props, as: 'div' } }],
['with class', { props: { ...props, class: 'min-h-full' } }],
['with ui', { props: { ...props, ui: { links: 'mt-16' } } }],
// Slots
['with default slot', { props, slots: { default: () => 'Default slot' } }],
['with statusCode slot', { props, slots: { statusCode: () => 'Status code slot' } }],
['with statusMessage slot', { props, slots: { statusMessage: () => 'Status message slot' } }],
['with message slot', { props, slots: { message: () => 'Message slot' } }],
['with links slot', { props, slots: { links: () => 'Links slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ErrorProps, slots?: Partial<ErrorSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, Error)
expect(html).toMatchSnapshot()
})
})