From 7d67b4d000582c89c6c353eea961dab641ab3de6 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 25 Apr 2024 11:45:24 +0200 Subject: [PATCH] test(NavigationMenu): consistent `items` with playground --- test/components/NavigationMenu.spec.ts | 57 +++++---- .../__snapshots__/NavigationMenu.spec.ts.snap | 116 ++++++++++++++++-- 2 files changed, 141 insertions(+), 32 deletions(-) diff --git a/test/components/NavigationMenu.spec.ts b/test/components/NavigationMenu.spec.ts index 94605fe8..f47699fb 100644 --- a/test/components/NavigationMenu.spec.ts +++ b/test/components/NavigationMenu.spec.ts @@ -3,26 +3,41 @@ import NavigationMenu, { type NavigationMenuProps, type NavigationMenuSlots } fr import ComponentRender from '../component-render' describe('NavigationMenu', () => { - const items = [{ - label: 'Profile', - avatar: { - src: 'https://avatars.githubusercontent.com/u/739984?v=4' - }, - badge: 100 - }, { - label: 'Modal', - icon: 'i-heroicons-home', - to: '/modal' - }, { - label: 'NavigationMenu', - icon: 'i-heroicons-chart-bar', - to: '/navigation-menu' - }, { - label: 'Popover', - icon: 'i-heroicons-command-line', - to: '/popover', - slot: 'custom' - }] + const items = [ + [{ + label: 'Profile', + active: true, + avatar: { + src: 'https://avatars.githubusercontent.com/u/739984?v=4' + }, + badge: 100, + select() { + console.log('Profile clicked') + } + }, { + label: 'Modal', + icon: 'i-heroicons-home', + to: '/modal' + }, { + label: 'NavigationMenu', + icon: 'i-heroicons-chart-bar', + to: '/navigation-menu' + }, { + label: 'Popover', + icon: 'i-heroicons-command-line', + to: '/popover' + }], [{ + label: 'Examples', + icon: 'i-heroicons-light-bulb', + to: 'https://ui.nuxt.com', + target: '_blank', + slot: 'custom' + }, { + label: 'Help', + icon: 'i-heroicons-question-mark-circle', + disabled: true + }] + ] const props = { items } @@ -38,7 +53,7 @@ describe('NavigationMenu', () => { ['with trailing slot', { props, slots: { trailing: () => 'Trailing slot' } }], ['with item slot', { props, slots: { item: () => 'Item slot' } }], ['with custom slot', { props, slots: { custom: () => 'Custom slot' } }] - ])('renders %s correctly', async (nameOrHtml: string, options: { props?: NavigationMenuProps, slots?: Partial> }) => { + ])('renders %s correctly', async (nameOrHtml: string, options: { props?: NavigationMenuProps, slots?: Partial> }) => { const html = await ComponentRender(nameOrHtml, options, NavigationMenu) expect(html).toMatchSnapshot() }) diff --git a/test/components/__snapshots__/NavigationMenu.spec.ts.snap b/test/components/__snapshots__/NavigationMenu.spec.ts.snap index ced8bc36..b1b9f7c9 100644 --- a/test/components/__snapshots__/NavigationMenu.spec.ts.snap +++ b/test/components/__snapshots__/NavigationMenu.spec.ts.snap @@ -4,7 +4,7 @@ exports[`NavigationMenu > renders with class correctly 1`] = ` "" `; @@ -24,14 +35,25 @@ exports[`NavigationMenu > renders with custom slot correctly 1`] = ` "