34 lines
1.3 KiB
TypeScript
34 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(): Page {
|
|
return pageSchema.parse({
|
|
title: 'Escape Regression',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
|
sections: [
|
|
{ type: 'features', props: { items: ['F<&>"', 'Safe'] } },
|
|
{ type: 'faq', props: { items: [{ q: 'Q<&>"', a: 'A<&>"' }] } },
|
|
],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 'SEO', description: 'Desc' },
|
|
})
|
|
}
|
|
|
|
describe('Exporter - HTML escape regression (Features/FAQ)', () => {
|
|
it('escapes HTML special characters in features items', () => {
|
|
const out = exportPage(makePage())
|
|
const html = out.html
|
|
// feature item should contain escaped characters < & > "
|
|
expect(html).toContain('<li class="feature-item">F<&>"</li>')
|
|
})
|
|
|
|
it('escapes HTML special characters in faq q/a', () => {
|
|
const out = exportPage(makePage())
|
|
const html = out.html
|
|
expect(html).toContain('<h3 class="faq-q">Q<&>"</h3>')
|
|
expect(html).toContain('<p class="faq-a">A<&>"</p>')
|
|
})
|
|
})
|