// tools/registry-render.test.mjs import { describe, it, expect } from 'vitest'; import { replaceRegion } from './registry-render.mjs'; describe('registry-render', () => { it('replaces auto-region between markers', () => { const input = `Header\n\nold content\n\nFooter`; const out = replaceRegion(input, 'foo', 'NEW CONTENT'); expect(out).toContain('NEW CONTENT'); expect(out).not.toContain('old content'); expect(out).toContain('Header'); expect(out).toContain('Footer'); }); it('preserves end marker exactly', () => { const input = `\nold\n`; const out = replaceRegion(input, 'foo', 'new'); expect(out).toMatch(/$/); }); it('throws if markers missing', () => { expect(() => replaceRegion('no markers here', 'foo', 'x')).toThrow(/Markers.*not found/); }); it('throws if only begin marker present', () => { expect(() => replaceRegion('\nstuff', 'foo', 'x')).toThrow(); }); it('handles multi-line rendered content', () => { const input = `\n`; const out = replaceRegion(input, 'foo', 'line1\nline2\nline3'); expect(out).toMatch(/line1\nline2\nline3/); }); });