summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-escape.test.js
blob: d2a4e79ca7380437c273ade20e0c1208ad10507f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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');
	});
});