diff --git a/test/components/ContextMenu.spec.ts b/test/components/ContextMenu.spec.ts index c173a56d..e2613521 100644 --- a/test/components/ContextMenu.spec.ts +++ b/test/components/ContextMenu.spec.ts @@ -1,9 +1,23 @@ +import { h, defineComponent } from 'vue' import { describe, it, expect } from 'vitest' import ContextMenu, { type ContextMenuProps, type ContextMenuSlots } from '../../src/runtime/components/ContextMenu.vue' -import ComponentRender from '../component-render' import theme from '#build/ui/context-menu' +import { mountSuspended } from '@nuxt/test-utils/runtime' + +const ContextMenuWrapper = defineComponent({ + components: { + UContextMenu: ContextMenu as any + }, + inheritAttrs: false, + template: ` +Right Click + + +` +}) -// FIXME: Can't force open state describe('ContextMenu', () => { const sizes = Object.keys(theme.variants.size) as any @@ -69,14 +83,17 @@ describe('ContextMenu', () => { ['with class', { props: { ...props, class: 'min-w-96' } }], ['with ui', { props: { ...props, ui: { itemLeadingIcon: 'size-4' } } }], // Slots - ['with default slot', { props, slots: { default: () => 'Default slot' } }], + ['with default slot', { props, slots: { default: () => h('span', 'Default slot') } }], ['with item slot', { props, slots: { item: () => 'Item slot' } }], ['with item-leading slot', { props, slots: { 'item-leading': () => 'Item leading slot' } }], ['with item-label slot', { props, slots: { 'item-label': () => 'Item label slot' } }], ['with item-trailing slot', { props, slots: { 'item-trailing': () => 'Item trailing slot' } }], ['with custom slot', { props, slots: { custom: () => 'Custom slot' } }] ])('renders %s correctly', async (nameOrHtml: string, options: { props?: ContextMenuProps, slots?: Partial> }) => { - const html = await ComponentRender(nameOrHtml, options, ContextMenu) - expect(html).toMatchSnapshot() + const wrapper = await mountSuspended(ContextMenuWrapper, options as any) + + await wrapper.find('span').trigger('click.right') + + expect(wrapper.html()).toMatchSnapshot() }) }) diff --git a/test/components/__snapshots__/ContextMenu-vue.spec.ts.snap b/test/components/__snapshots__/ContextMenu-vue.spec.ts.snap index 00dab32d..9f0606f1 100644 --- a/test/components/__snapshots__/ContextMenu-vue.spec.ts.snap +++ b/test/components/__snapshots__/ContextMenu-vue.spec.ts.snap @@ -1,12 +1,47 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`ContextMenu > renders with class correctly 1`] = ` -" +"Right Click - +
+ +
@@ -14,12 +49,47 @@ exports[`ContextMenu > renders with class correctly 1`] = ` `; exports[`ContextMenu > renders with custom slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -27,12 +97,47 @@ exports[`ContextMenu > renders with custom slot correctly 1`] = ` `; exports[`ContextMenu > renders with default slot correctly 1`] = ` -"Default slot +"Default slot - +
+ +
@@ -40,7 +145,7 @@ exports[`ContextMenu > renders with default slot correctly 1`] = ` `; exports[`ContextMenu > renders with disabled correctly 1`] = ` -" +"Right Click @@ -53,12 +158,29 @@ exports[`ContextMenu > renders with disabled correctly 1`] = ` `; exports[`ContextMenu > renders with item slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -66,12 +188,47 @@ exports[`ContextMenu > renders with item slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-label slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -79,12 +236,33 @@ exports[`ContextMenu > renders with item-label slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-leading slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -92,12 +270,45 @@ exports[`ContextMenu > renders with item-leading slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-trailing slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -105,12 +316,47 @@ exports[`ContextMenu > renders with item-trailing slot correctly 1`] = ` `; exports[`ContextMenu > renders with items correctly 1`] = ` -" +"Right Click - +
+ +
@@ -118,12 +364,55 @@ exports[`ContextMenu > renders with items correctly 1`] = ` `; exports[`ContextMenu > renders with labelKey correctly 1`] = ` -" +"Right Click - +
+ +
@@ -131,12 +420,47 @@ exports[`ContextMenu > renders with labelKey correctly 1`] = ` `; exports[`ContextMenu > renders with size lg correctly 1`] = ` -" +"Right Click - +
+ +
@@ -144,12 +468,47 @@ exports[`ContextMenu > renders with size lg correctly 1`] = ` `; exports[`ContextMenu > renders with size md correctly 1`] = ` -" +"Right Click - +
+ +
@@ -157,12 +516,47 @@ exports[`ContextMenu > renders with size md correctly 1`] = ` `; exports[`ContextMenu > renders with size sm correctly 1`] = ` -" +"Right Click - +
+ +
@@ -170,12 +564,47 @@ exports[`ContextMenu > renders with size sm correctly 1`] = ` `; exports[`ContextMenu > renders with size xl correctly 1`] = ` -" +"Right Click - +
+ +
@@ -183,12 +612,47 @@ exports[`ContextMenu > renders with size xl correctly 1`] = ` `; exports[`ContextMenu > renders with size xs correctly 1`] = ` -" +"Right Click - +
+ +
@@ -196,12 +660,47 @@ exports[`ContextMenu > renders with size xs correctly 1`] = ` `; exports[`ContextMenu > renders with ui correctly 1`] = ` -" +"Right Click - +
+ +
diff --git a/test/components/__snapshots__/ContextMenu.spec.ts.snap b/test/components/__snapshots__/ContextMenu.spec.ts.snap index 00dab32d..e07bbbc4 100644 --- a/test/components/__snapshots__/ContextMenu.spec.ts.snap +++ b/test/components/__snapshots__/ContextMenu.spec.ts.snap @@ -1,12 +1,49 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`ContextMenu > renders with class correctly 1`] = ` -" +"Right Click - +
+ +
@@ -14,12 +51,49 @@ exports[`ContextMenu > renders with class correctly 1`] = ` `; exports[`ContextMenu > renders with custom slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -27,12 +101,49 @@ exports[`ContextMenu > renders with custom slot correctly 1`] = ` `; exports[`ContextMenu > renders with default slot correctly 1`] = ` -"Default slot +"Default slot - +
+ +
@@ -40,7 +151,7 @@ exports[`ContextMenu > renders with default slot correctly 1`] = ` `; exports[`ContextMenu > renders with disabled correctly 1`] = ` -" +"Right Click @@ -53,12 +164,29 @@ exports[`ContextMenu > renders with disabled correctly 1`] = ` `; exports[`ContextMenu > renders with item slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -66,12 +194,49 @@ exports[`ContextMenu > renders with item slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-label slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -79,12 +244,37 @@ exports[`ContextMenu > renders with item-label slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-leading slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -92,12 +282,45 @@ exports[`ContextMenu > renders with item-leading slot correctly 1`] = ` `; exports[`ContextMenu > renders with item-trailing slot correctly 1`] = ` -" +"Right Click - +
+ +
@@ -105,12 +328,49 @@ exports[`ContextMenu > renders with item-trailing slot correctly 1`] = ` `; exports[`ContextMenu > renders with items correctly 1`] = ` -" +"Right Click - +
+ +
@@ -118,12 +378,57 @@ exports[`ContextMenu > renders with items correctly 1`] = ` `; exports[`ContextMenu > renders with labelKey correctly 1`] = ` -" +"Right Click - +
+ +
@@ -131,12 +436,49 @@ exports[`ContextMenu > renders with labelKey correctly 1`] = ` `; exports[`ContextMenu > renders with size lg correctly 1`] = ` -" +"Right Click - +
+ +
@@ -144,12 +486,49 @@ exports[`ContextMenu > renders with size lg correctly 1`] = ` `; exports[`ContextMenu > renders with size md correctly 1`] = ` -" +"Right Click - +
+ +
@@ -157,12 +536,49 @@ exports[`ContextMenu > renders with size md correctly 1`] = ` `; exports[`ContextMenu > renders with size sm correctly 1`] = ` -" +"Right Click - +
+ +
@@ -170,12 +586,49 @@ exports[`ContextMenu > renders with size sm correctly 1`] = ` `; exports[`ContextMenu > renders with size xl correctly 1`] = ` -" +"Right Click - +
+ +
@@ -183,12 +636,49 @@ exports[`ContextMenu > renders with size xl correctly 1`] = ` `; exports[`ContextMenu > renders with size xs correctly 1`] = ` -" +"Right Click - +
+ +
@@ -196,12 +686,49 @@ exports[`ContextMenu > renders with size xs correctly 1`] = ` `; exports[`ContextMenu > renders with ui correctly 1`] = ` -" +"Right Click - +
+ +