diff options
author | 2022-08-05 10:35:47 -0500 | |
---|---|---|
committer | 2022-08-05 10:35:47 -0500 | |
commit | e569f0a5c7b56c4cce7afe95335b0aee6ac3d298 (patch) | |
tree | 9d008a74846e49fd7e13d3979c4db44162bdd8f4 /packages/integrations/mdx/test/mdx-escape.test.js | |
parent | e7bee22d18c6f1299d99793da9bea00915d144a4 (diff) | |
download | astro-e569f0a5c7b56c4cce7afe95335b0aee6ac3d298.tar.gz astro-e569f0a5c7b56c4cce7afe95335b0aee6ac3d298.tar.zst astro-e569f0a5c7b56c4cce7afe95335b0aee6ac3d298.zip |
Handle edge case in jsx-runtime (#4158)
* fix(#4135): handle edge case in jsx-runtime
* test: add mdx test case
* chore: fix utils reference
* test: fix mdx escape test
Co-authored-by: Nate Moore <nate@astro.build>
Diffstat (limited to 'packages/integrations/mdx/test/mdx-escape.test.js')
-rw-r--r-- | packages/integrations/mdx/test/mdx-escape.test.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-escape.test.js b/packages/integrations/mdx/test/mdx-escape.test.js new file mode 100644 index 000000000..d2a4e79ca --- /dev/null +++ b/packages/integrations/mdx/test/mdx-escape.test.js @@ -0,0 +1,32 @@ +import mdx from '@astrojs/mdx'; + +import { expect } from 'chai'; +import { parseHTML } from 'linkedom'; +import { loadFixture } from '../../../astro/test/test-utils.js'; + +const FIXTURE_ROOT = new URL('./fixtures/mdx-escape/', import.meta.url); + +describe('MDX frontmatter', () => { + let fixture; + before(async () => { + fixture = await loadFixture({ + root: FIXTURE_ROOT, + integrations: [mdx()], + }); + await fixture.build(); + }); + + it('does not have unescaped HTML at top-level', async () => { + const html = await fixture.readFile('/index.html'); + const { document } = parseHTML(html); + + expect(document.body.textContent).to.not.include('<em'); + }); + + it('does not have unescaped HTML inside html tags', async () => { + const html = await fixture.readFile('/html-tag/index.html'); + const { document } = parseHTML(html); + + expect(document.body.textContent).to.not.include('<em'); + }); +}); |