2022-07-28 09:58:44 -05:00
|
|
|
import mdx from '@astrojs/mdx';
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
import * as assert from 'node:assert/strict';
|
2024-02-21 09:08:19 -05:00
|
|
|
import { before, describe, it } from 'node:test';
|
2022-07-28 09:58:44 -05:00
|
|
|
import * as cheerio from 'cheerio';
|
2024-02-21 09:08:19 -05:00
|
|
|
import { loadFixture } from '../../../astro/test/test-utils.js';
|
2022-07-28 09:58:44 -05:00
|
|
|
|
|
|
|
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);
|
2024-01-31 03:37:34 -05:00
|
|
|
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,
|
2022-07-28 10:00:32 -05:00
|
|
|
'file is included'
|
|
|
|
);
|
2022-07-28 09:58:44 -05:00
|
|
|
});
|
|
|
|
});
|