import { describe, it, expect } from 'vitest' import { exportPage } from '@/lib/exporter/html' import { pageSchema, type Page } from '@/lib/schema/page' function makePage(overrides: Partial = {}): Page { const base: Page = { title: 'Hero Edge', locale: 'en', theme: { primaryColor: '#2563eb', fontFamily: 'Inter' }, sections: [ { type: 'hero', props: { heading: 'Welcome', subheading: ' ', imageUrl: 'https://img.example/h.png' } }, ] as Page['sections'], form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' }, seo: { title: 't', description: 'd' }, } return pageSchema.parse({ ...base, ...overrides }) } describe('Exporter - hero edge cases', () => { it('omits subheading when whitespace-only', () => { const out = exportPage(makePage()) expect(out.html).toContain('

Welcome

') expect(out.html).not.toMatch(/
[\s\S]*

\s*<\/p>/) }) it('trims subheading content', () => { const out = exportPage(makePage({ sections: [ { type: 'hero', props: { heading: 'Welcome', subheading: ' Hello world ', imageUrl: 'https://img.example/h.png' } } ] as Page['sections'] })) expect(out.html).toContain('

Hello world

') }) })