diff options
Diffstat (limited to 'packages/integrations/mdx/test')
-rw-r--r-- | packages/integrations/mdx/test/fixtures/mdx-optimize/astro.config.mjs | 40 | ||||
-rw-r--r-- | packages/integrations/mdx/test/mdx-optimize.test.js | 11 |
2 files changed, 45 insertions, 6 deletions
diff --git a/packages/integrations/mdx/test/fixtures/mdx-optimize/astro.config.mjs b/packages/integrations/mdx/test/fixtures/mdx-optimize/astro.config.mjs index 204549479..a3626c3a3 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-optimize/astro.config.mjs +++ b/packages/integrations/mdx/test/fixtures/mdx-optimize/astro.config.mjs @@ -1,9 +1,37 @@ import mdx from '@astrojs/mdx'; export default { - integrations: [mdx({ - optimize: { - ignoreElementNames: ['strong'] - } - })] -} + integrations: [ + mdx({ + optimize: { + ignoreElementNames: ['strong'], + }, + }), + ], + markdown: { + rehypePlugins: [ + () => { + return (tree) => { + tree.children.push({ + type: 'root', + children: [ + { + type: 'element', + tagName: 'p', + properties: { + id: 'injected-root-hast', + }, + children: [ + { + type: 'text', + value: 'Injected root hast from rehype plugin', + }, + ], + }, + ], + }); + }; + }, + ], + }, +}; diff --git a/packages/integrations/mdx/test/mdx-optimize.test.js b/packages/integrations/mdx/test/mdx-optimize.test.js index 47acfdff8..c45ecda15 100644 --- a/packages/integrations/mdx/test/mdx-optimize.test.js +++ b/packages/integrations/mdx/test/mdx-optimize.test.js @@ -47,4 +47,15 @@ describe('MDX optimize', () => { assert.notEqual(blockquote, null); assert.equal(blockquote.textContent.includes('I like pancakes'), true); }); + + it('renders MDX with rehype plugin that incorrectly injects root hast node', async () => { + const html = await fixture.readFile('/import/index.html'); + const { document } = parseHTML(html); + + assert.doesNotMatch(html, /set:html=/); + assert.equal( + document.getElementById('injected-root-hast').textContent, + 'Injected root hast from rehype plugin', + ); + }); }); |