Files
landing-builder/lib/exporter/sections.regression.cta-testimonials.test.ts

36 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { exportPage } from '@/lib/exporter/html'
import { pageSchema, type Page } from '@/lib/schema/page'
function makePage(): Page {
return pageSchema.parse({
title: 'Sections Regression CTA/Testimonials',
locale: 'en',
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
sections: [
{ type: 'testimonials', props: { items: [{ author: 'Linus', quote: 'Simple and fast' }] } },
{ type: 'cta', props: { text: 'Get Started', href: '/start' } },
],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
seo: { title: 'SEO', description: 'Desc' },
})
}
describe('Exporter - CTA and Testimonials regression', () => {
it('renders testimonials figure/blockquote/figcaption structure', () => {
const out = exportPage(makePage())
const html = out.html
expect(html).toMatch(/<section class="testimonials" aria-labelledby="testimonials-heading">/)
expect(html).toMatch(/<h2 id="testimonials-heading">Testimonials<\/h2>/)
expect(html).toMatch(/<figure class="testimonial">[\s\S]*<blockquote>“Simple and fast”<\/blockquote>[\s\S]*<figcaption>— Linus<\/figcaption>[\s\S]*<\/figure>/)
})
it('renders CTA link with correct class and href', () => {
const out = exportPage(makePage())
const html = out.html
expect(html).toMatch(/<section class="cta" aria-labelledby="cta-heading">/)
expect(html).toMatch(/<h2 id="cta-heading">CTA<\/h2>/)
expect(html).toMatch(/<a class="btn-cta" href="\/start">Get Started<\/a>/)
})
})