33 lines
1.3 KiB
TypeScript
33 lines
1.3 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: 'CTA Edge',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
|
sections: [
|
|
{ type: 'cta', props: { text: ' ', href: '#' } },
|
|
{ type: 'features', props: { items: ['One'] } },
|
|
] 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 - CTA edge cases', () => {
|
|
it('drops CTA section when text is whitespace-only', () => {
|
|
const out = exportPage(makePage())
|
|
expect(out.html).not.toContain('<section class="cta"')
|
|
expect(out.html).not.toContain('<a class="btn-cta"')
|
|
})
|
|
|
|
it('renders CTA when text is valid after trimming', () => {
|
|
const out = exportPage(makePage({ sections: [ { type: 'cta', props: { text: ' Buy Now ', href: '#' } } ] as Page['sections'] }))
|
|
expect(out.html).toContain('<a class="btn-cta" href="#">Buy Now</a>')
|
|
})
|
|
})
|