32 lines
1.2 KiB
TypeScript
32 lines
1.2 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: 'SEO/Perf 2',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
|
sections: [
|
|
{ type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img.example/hero.png' } },
|
|
],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 'SEO2', description: 'Desc2' },
|
|
})
|
|
}
|
|
|
|
describe('Exporter - theme-color meta and hero image intrinsic size', () => {
|
|
it('includes theme-color meta using page.theme.primaryColor', () => {
|
|
const out = exportPage(makePage())
|
|
const html = out.html
|
|
expect(html).toMatch(/<meta name="theme-color" content="#0ea5e9"\s*\/>/)
|
|
})
|
|
|
|
it('renders hero image with width/height attributes for CLS reduction', () => {
|
|
const out = exportPage(makePage())
|
|
const html = out.html
|
|
expect(html).toMatch(/<img[^>]*\swidth="[0-9]+"/)
|
|
expect(html).toMatch(/<img[^>]*\sheight="[0-9]+"/)
|
|
})
|
|
})
|