mdx-escape.test.js 973 B

123456789101112131415161718192021222324252627282930313233
  1. import mdx from '@astrojs/mdx';
  2. import { describe, it, before } from 'node:test';
  3. import * as assert from 'node:assert/strict';
  4. import { parseHTML } from 'linkedom';
  5. import { loadFixture } from '../../../astro/test/test-utils.js';
  6. const FIXTURE_ROOT = new URL('./fixtures/mdx-escape/', import.meta.url);
  7. describe('MDX frontmatter', () => {
  8. let fixture;
  9. before(async () => {
  10. fixture = await loadFixture({
  11. root: FIXTURE_ROOT,
  12. integrations: [mdx()],
  13. });
  14. await fixture.build();
  15. });
  16. it('does not have unescaped HTML at top-level', async () => {
  17. const html = await fixture.readFile('/index.html');
  18. const { document } = parseHTML(html);
  19. assert.equal(document.body.textContent.includes('<em'), false);
  20. });
  21. it('does not have unescaped HTML inside html tags', async () => {
  22. const html = await fixture.readFile('/html-tag/index.html');
  23. const { document } = parseHTML(html);
  24. assert.equal(document.body.textContent.includes('<em'), false);
  25. });
  26. });