diff options
author | 2022-07-28 10:58:44 -0400 | |
---|---|---|
committer | 2022-07-28 10:58:44 -0400 | |
commit | 6120a71e5425ad55a17ddac800d64a3f50273bce (patch) | |
tree | 012c7405c55f593e31e6bf5a035b34a6761ba65b /packages/integrations/mdx/test/mdx-get-static-paths.test.js | |
parent | 6fb95dbdd6744241e202b3d68509ec5aac0bb07e (diff) | |
download | astro-6120a71e5425ad55a17ddac800d64a3f50273bce.tar.gz astro-6120a71e5425ad55a17ddac800d64a3f50273bce.tar.zst astro-6120a71e5425ad55a17ddac800d64a3f50273bce.zip |
Ensure file and url are always present in MDX for Astro.glob (#4076)
Diffstat (limited to 'packages/integrations/mdx/test/mdx-get-static-paths.test.js')
-rw-r--r-- | packages/integrations/mdx/test/mdx-get-static-paths.test.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-get-static-paths.test.js b/packages/integrations/mdx/test/mdx-get-static-paths.test.js new file mode 100644 index 000000000..f5d48922c --- /dev/null +++ b/packages/integrations/mdx/test/mdx-get-static-paths.test.js @@ -0,0 +1,29 @@ +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'); + }); +}); |