mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
38765c367d
Co-authored-by: Baptiste Leproux <leproux.baptiste@gmail.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest'
|
|
import { axe } from 'vitest-axe'
|
|
import type { Editor } from '@tiptap/vue-3'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import EditorDragHandle from '../../src/runtime/components/EditorDragHandle.vue'
|
|
import type { EditorDragHandleProps, EditorDragHandleSlots } from '../../src/runtime/components/EditorDragHandle.vue'
|
|
import ComponentRender from '../component-render'
|
|
|
|
describe('EditorDragHandle', () => {
|
|
const props = { editor: { registerPlugin: vi.fn() } as unknown as Editor }
|
|
|
|
it.each([
|
|
// Props
|
|
['with as', { props: { ...props, as: 'section' } }],
|
|
['with class', { props: { ...props, class: 'items-start' } }],
|
|
['with ui', { props: { ...props, ui: { handle: 'px-4' } } }],
|
|
// Slots
|
|
['with default slot', { props, slots: { default: () => 'Default slot' } }]
|
|
])('renders %s correctly', async (nameOrHtml: string, options: { props?: EditorDragHandleProps, slots?: Partial<EditorDragHandleSlots> }) => {
|
|
const html = await ComponentRender(nameOrHtml, options, EditorDragHandle)
|
|
expect(html).toMatchSnapshot()
|
|
})
|
|
|
|
it('passes accessibility tests', async () => {
|
|
const wrapper = await mountSuspended(EditorDragHandle, {
|
|
props
|
|
})
|
|
|
|
expect(await axe(wrapper.element)).toHaveNoViolations()
|
|
})
|
|
})
|