2022-08-05 10:35:47 -05:00
|
|
|
import mdx from '@astrojs/mdx';
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
import * as assert from 'node:assert/strict';
|
|
|
|
import { before, describe, it } from 'node:test';
|
2022-08-05 10:35:47 -05:00
|
|
|
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);
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
assert.equal(document.body.textContent.includes('<em'), false);
|
2022-08-05 10:35:47 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not have unescaped HTML inside html tags', async () => {
|
|
|
|
const html = await fixture.readFile('/html-tag/index.html');
|
|
|
|
const { document } = parseHTML(html);
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
assert.equal(document.body.textContent.includes('<em'), false);
|
2022-08-05 10:35:47 -05:00
|
|
|
});
|
|
|
|
});
|