summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/css-head-mdx.test.js
blob: 2b1dcdfe7bcd7eb8e19ae07e067ba5715183b7b4 (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
33
import mdx from '@astrojs/mdx';

import { expect } from 'chai';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';

describe('Head injection w/ MDX', () => {
	let fixture;

	before(async () => {
		fixture = await loadFixture({
			root: new URL('./fixtures/css-head-mdx/', import.meta.url),
			integrations: [mdx()],
		});
	});

	describe('build', () => {
		before(async () => {
			await fixture.build();
		});

		it('only injects contents into head', async () => {
			const html = await fixture.readFile('/indexThree/index.html');
			const { document } = parseHTML(html);

			const links = document.querySelectorAll('head link[rel=stylesheet]');
			expect(links).to.have.a.lengthOf(1);

			const scripts = document.querySelectorAll('head script[type=module]');
			expect(scripts).to.have.a.lengthOf(1);
		});
	});
});