diff --git a/apps/app/src/components-v2/shared/PageHead.stories.ts b/apps/app/src/components-v2/shared/PageHead.stories.ts new file mode 100644 index 00000000..3464a64c --- /dev/null +++ b/apps/app/src/components-v2/shared/PageHead.stories.ts @@ -0,0 +1,24 @@ +import type { Meta, StoryObj } from '@storybook/vue3-vite' +import Button from 'primevue/button' +import PageHead from '@/components-v2/shared/PageHead.vue' + +const meta: Meta = { + title: 'Shared/PageHead', + component: PageHead, + tags: ['autodocs'], + argTypes: { title: { control: 'text' }, sub: { control: 'text' } }, +} + +export default meta +type Story = StoryObj + +export const TitleOnly: Story = { args: { title: 'Evenementen' } } +export const WithSub: Story = { args: { title: 'Evenementen', sub: '3 actieve evenementen' } } +export const WithActions: Story = { + args: { title: 'Evenementen', sub: '3 actief' }, + render: args => ({ + components: { PageHead, Button }, + setup: () => ({ args }), + template: '', + }), +} diff --git a/apps/app/src/components-v2/shared/PageHead.vue b/apps/app/src/components-v2/shared/PageHead.vue new file mode 100644 index 00000000..b6aa0a52 --- /dev/null +++ b/apps/app/src/components-v2/shared/PageHead.vue @@ -0,0 +1,27 @@ + + + diff --git a/apps/app/src/components-v2/shared/__tests__/PageHead.spec.ts b/apps/app/src/components-v2/shared/__tests__/PageHead.spec.ts new file mode 100644 index 00000000..268981f4 --- /dev/null +++ b/apps/app/src/components-v2/shared/__tests__/PageHead.spec.ts @@ -0,0 +1,24 @@ +import { mount } from '@vue/test-utils' +import { describe, expect, it } from 'vitest' +import PageHead from '@/components-v2/shared/PageHead.vue' + +describe('PageHead', () => { + it('renders the title and optional sub', () => { + const w = mount(PageHead, { props: { title: 'Evenementen', sub: '3 actief' } }) + + expect(w.get('h1').text()).toBe('Evenementen') + expect(w.text()).toContain('3 actief') + }) + + it('omits the sub element when not provided', () => { + const w = mount(PageHead, { props: { title: 'Evenementen' } }) + + expect(w.find('[data-sub]').exists()).toBe(false) + }) + + it('renders the #actions slot', () => { + const w = mount(PageHead, { props: { title: 'X' }, slots: { actions: '' } }) + + expect(w.get('button').text()).toBe('New') + }) +})