Files
landing-builder/lib/exporter/og.test.ts
T
2025-11-14 16:40:45 +09:00

34 lines
1.4 KiB
TypeScript

import { describe, expect, test } from 'vitest'
import { exportPage } from './html'
import { pageSchema, type Page } from '@/lib/schema/page'
describe('Exporter - OG image meta', () => {
test('includes og:image meta when seo.ogImage is provided', () => {
const page: Page = pageSchema.parse({
title: 'T',
locale: 'en',
theme: { primaryColor: '#000000', fontFamily: 'Inter' },
sections: [],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
seo: { title: 'SEO', description: 'Desc', ogImage: 'https://example.com/og.png' },
})
const out = exportPage(page)
expect(out.html).toContain('<meta property="og:image" content="https://example.com/og.png" />')
})
test('omits og:image meta when seo.ogImage is empty', () => {
const page: Page = pageSchema.parse({
title: 'T',
locale: 'en',
theme: { primaryColor: '#000000', fontFamily: 'Inter' },
sections: [],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
analytics: { ga4MeasurementId: '', metaPixelId: '', customHeadHtml: '' },
seo: { title: 'SEO', description: 'Desc' },
})
const out = exportPage(page)
expect(out.html).not.toContain('og:image')
})
})