aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-get-static-paths.test.js
blob: 96f0dc9a43f7803e15acb4dc8bba5d4b598eec45 (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
34
import mdx from '@astrojs/mdx';

import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from '../../../astro/test/test-utils.js';

const FIXTURE_ROOT = new URL('./fixtures/mdx-get-static-paths', import.meta.url);

describe('getStaticPaths', () => {
	/** @type {import('astro/test/test-utils').Fixture} */
	let fixture;
	before(async () => {
		fixture = await loadFixture({
			root: FIXTURE_ROOT,
			integrations: [mdx()],
		});
		await fixture.build();
	});

	it('Provides file and url', async () => {
		const html = await fixture.readFile('/one/index.html');

		const $ = cheerio.load(html);
		assert.equal($('p').text(), 'First mdx file');
		assert.equal($('#one').text(), 'hello', 'Frontmatter included');
		assert.equal($('#url').text(), 'src/content/1.mdx', 'url is included');
		assert.equal(
			$('#file').text().includes('fixtures/mdx-get-static-paths/src/content/1.mdx'),
			true,
			'file is included',
		);
	});
});