/** * Build-output test for PostHeader.astro * Checks source content for expected structure, props, styles, and responsive breakpoints. */ import { readFileSync, existsSync } from 'fs'; import { resolve } from 'path'; const srcPath = resolve('src/components/PostHeader.astro'); let failures = 0; let passes = 0; function assert(condition, label) { if (condition) { console.log(` ✓ ${label}`); passes++; } else { console.error(` ✗ FAIL: ${label}`); failures++; } } // ── Source file existence ── console.log('\n--- Source file checks ---'); assert( existsSync(srcPath), 'src/components/PostHeader.astro exists' ); if (existsSync(srcPath)) { const src = readFileSync(srcPath, 'utf-8'); // ── Props interface ── console.log('\n--- Props interface checks ---'); assert( /title:\s*string/.test(src), 'Props has title: string' ); assert( /date:\s*Date/.test(src), 'Props has date: Date' ); assert( /type\?:\s*string/.test(src), 'Props has type?: string' ); assert( /readingTime\?:\s*number/.test(src), 'Props has readingTime?: number' ); // ── Default values ── console.log('\n--- Default value checks ---'); assert( src.includes("'post'") || src.includes('"post"'), 'type defaults to "post"' ); // ── Date formatting ── console.log('\n--- Date formatting checks ---'); assert( src.includes("toLocaleDateString('en-US'") || src.includes('toLocaleDateString("en-US"'), 'Uses toLocaleDateString with en-US locale' ); assert( src.includes("'numeric'") || src.includes('"numeric"'), 'Date format includes numeric option' ); assert( src.includes("'long'") || src.includes('"long"'), 'Date format includes long month' ); assert( src.includes("toISOString()"), 'Computes ISO date string' ); // ── HTML structure ── console.log('\n--- HTML structure checks ---'); assert( src.includes('post-header'), 'Has .post-header class' ); assert( /]/.test(src), 'Uses
element' ); assert( src.includes('badge'), 'Has .badge class' ); assert( /]*class.*badge/.test(src) || /]*badge/.test(src), 'Badge uses element' ); assert( /

element for title' ); assert( src.includes('title') && src.includes('class'), 'Has .title class' ); assert( /]*class.*meta/.test(src) || src.includes("class=\"meta\"") || src.includes("class='meta'"), 'Meta uses

element with .meta class' ); assert( /]*datetime/.test(src), 'Has