import { describe, test, expect } from 'vitest'; import { TextBlock } from './TextBlock'; const toHtml = (TextBlock as any).toHtml; describe('TextBlock.toHtml text escaping (attacker-controlled `text` prop)', () => { test('a tag-breakout attempt in text is neutralized (no injected element)', () => { const { html } = toHtml({ text: '

' }, ''); expect(html).not.toContain(' { const { html } = toHtml({ text: 'Tom & Jerry' }, ''); expect(html).toContain('Tom & Jerry'); }); test('a normal text value still renders unchanged', () => { const { html } = toHtml({ text: 'Hello world' }, ''); expect(html).toBe('

Hello world

'); }); });