diff --git a/openless-all/app/src/lib/qaMarkdown.test.ts b/openless-all/app/src/lib/qaMarkdown.test.ts new file mode 100644 index 00000000..77638c09 --- /dev/null +++ b/openless-all/app/src/lib/qaMarkdown.test.ts @@ -0,0 +1,34 @@ +import { renderQaMarkdown } from './qaMarkdown'; + +function assertIncludes(text: string, expected: string, name: string) { + if (!text.includes(expected)) { + throw new Error(`${name}: expected to include "${expected}", got "${text}"`); + } +} + +function assertNotIncludes(text: string, expected: string, name: string) { + if (text.includes(expected)) { + throw new Error(`${name}: expected not to include "${expected}", got "${text}"`); + } +} + +const htmlEscaped = renderQaMarkdown(''); +assertIncludes(htmlEscaped, '<img src=x onerror=alert(1)>', 'raw html should be escaped'); +assertNotIncludes(htmlEscaped, '