summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-get-static-paths.test.js
blob: b4dc179d08fd8c2921fa17db078ac3c70e0b6fb2 (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 { loadFixture } from '../../../astro/test/test-utils.js';
import * as cheerio from 'cheerio';

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);
		expect($('p').text()).to.equal('First mdx file');
		expect($('#one').text()).to.equal('hello', 'Frontmatter included');
		expect($('#url').text()).to.equal('/src/content/1.mdx', 'url is included');
		expect($('#file').text()).to.contain(
			'fixtures/mdx-get-static-paths/src/content/1.mdx',
			'file is included'
		);
	});
});