14 lines
498 B
TypeScript
14 lines
498 B
TypeScript
import { describe, test, expect } from 'vitest';
|
|||
|
|
import { HtmlBlock } from './HtmlBlock';
|
||
|
|
|
||
|
|
const toHtml = (HtmlBlock as any).toHtml;
|
||
|
|
|
||
|
|
describe('HtmlBlock.toHtml sanitizes raw code (A4.1)', () => {
|
||
|
|
test('strips <script> and on-handlers from exported output', () => {
|
||
|
|
const { html } = toHtml({ code: '<script>alert(1)</script><p onclick="x">hi</p>' }, '');
|
||
|
|
expect(html).not.toContain('<script');
|
||
|
|
expect(html).not.toContain('onclick');
|
||
|
|
expect(html).toContain('<p>hi</p>');
|
||
|
|
});
|
||
|
|
});
|