import { describe, expect, it } from 'vitest'; import { injectCms, type LiveData } from './hostInjector.ts'; const AUTHORED = 'https://andreaslop.nl'; const page = (inner: string) => `${inner}`; const pakket = (slug: string, price: string, extra = {}) => ({ slug, title: slug.toUpperCase(), price, features: ['a'], displayOrder: 0, ...extra, }); const live = ( offerings: unknown, banners: LiveData['banners'] = { top: null, bottom: null }, ): LiveData => ({ offerings, banners }); const run = (html: string, data: LiveData, publicBaseUrl?: string) => injectCms(html, { data, authoredBaseUrl: AUTHORED, publicBaseUrl }); describe('injectCms regions', () => { const region = (name: string) => `baked`; it('writes the lists between the markers and keeps the markers', () => { const out = run( page( region('OFFERINGS-HTML') + region('BANNER-TOP-HTML') + region('BANNER-BOTTOM-HTML'), ), live([pakket('newborn', '€ 185')], { top: { text: 'Boven' }, bottom: { title: 'Onder' }, }), ); expect(out).toContain( '