41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
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> = {}): Page {
|
|
const base: Page = {
|
|
title: 'Edge P3',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
|
sections: [
|
|
{ type: 'faq', props: { items: [ { q: 'VeryVeryVeryVeryVeryLongWordWithoutSpaces', a: 'AnotherSuperLongUnbreakableWord' } ] } },
|
|
{ type: 'testimonials', props: { items: [
|
|
{ author: ' ', quote: 'Great!' },
|
|
{ author: 'Alice', quote: 'Nice' },
|
|
] } },
|
|
] 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 - phase3 edge cases', () => {
|
|
it('omits testimonial author line when author is blank', () => {
|
|
const out = exportPage(makePage())
|
|
const html = out.html
|
|
// First item author blank -> no figcaption for that blockquote
|
|
expect(html).toMatch(/<blockquote>“Great!\”<\/blockquote>[\s\S]*?<\/figure>/)
|
|
// Ensure the next item with author renders figcaption
|
|
expect(html).toMatch(/<figcaption>— Alice<\/figcaption>/)
|
|
})
|
|
|
|
it('adds word-break/overflow-wrap for FAQ q/a to avoid overflow', () => {
|
|
const out = exportPage(makePage())
|
|
const css = out.css
|
|
expect(css).toMatch(/\.faq-q\{[\s\S]*(?:overflow-wrap:anywhere|word-break:break-word)/i)
|
|
expect(css).toMatch(/\.faq-a\{[\s\S]*(?:overflow-wrap:anywhere|word-break:break-word)/i)
|
|
})
|
|
})
|