Files
nuxt__ui/test/components/Editor.spec.ts
Benjamin Canac 38765c367d feat(Editor): new component (#5407)
Co-authored-by: Baptiste Leproux <leproux.baptiste@gmail.com>
2025-12-03 18:19:16 +01:00

33 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { axe } from 'vitest-axe'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import Editor from '../../src/runtime/components/Editor.vue'
import type { EditorProps, EditorSlots } from '../../src/runtime/components/Editor.vue'
import ComponentRender from '../component-render'
describe('Editor', () => {
const props = {}
it.each([
// Props
['with as', { props: { as: 'section' } }],
['with class', { props: { class: 'min-h-80' } }],
['with ui', { props: { ui: { base: 'sm:px-14' } } }],
// Slots
['with default slot', { props, slots: { default: () => 'Default slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: EditorProps, slots?: Partial<EditorSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, Editor)
expect(html).toMatchSnapshot()
})
it('passes accessibility tests', async () => {
const wrapper = await mountSuspended(Editor, {
props
})
expect(await axe(wrapper.element)).toHaveNoViolations()
wrapper.unmount()
})
})