mdx-get-static-paths.test.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import mdx from '@astrojs/mdx';
  2. import { describe, it, before } from 'node:test';
  3. import * as assert from 'node:assert/strict';
  4. import { loadFixture } from '../../../astro/test/test-utils.js';
  5. import * as cheerio from 'cheerio';
  6. const FIXTURE_ROOT = new URL('./fixtures/mdx-get-static-paths', import.meta.url);
  7. describe('getStaticPaths', () => {
  8. /** @type {import('astro/test/test-utils').Fixture} */
  9. let fixture;
  10. before(async () => {
  11. fixture = await loadFixture({
  12. root: FIXTURE_ROOT,
  13. integrations: [mdx()],
  14. });
  15. await fixture.build();
  16. });
  17. it('Provides file and url', async () => {
  18. const html = await fixture.readFile('/one/index.html');
  19. const $ = cheerio.load(html);
  20. assert.equal($('p').text(), 'First mdx file');
  21. assert.equal($('#one').text(), 'hello', 'Frontmatter included');
  22. assert.equal($('#url').text(), 'src/content/1.mdx', 'url is included');
  23. assert.equal(
  24. $('#file').text().includes('fixtures/mdx-get-static-paths/src/content/1.mdx'),
  25. true,
  26. 'file is included'
  27. );
  28. });
  29. });