diff options
author | 2023-08-31 11:31:01 -0400 | |
---|---|---|
committer | 2023-08-31 11:31:01 -0400 | |
commit | 0752cf3688eaac535ceda1ebcd22ccaf20b2171f (patch) | |
tree | e3c606d1f862ea6f93cd49c6fb5ac10b11efd175 /packages/integrations/mdx/test/mdx-plus-react.test.js | |
parent | 8fff0e9aebec5ff8c2516ed6dbcccb307c20ce45 (diff) | |
download | astro-0752cf3688eaac535ceda1ebcd22ccaf20b2171f.tar.gz astro-0752cf3688eaac535ceda1ebcd22ccaf20b2171f.tar.zst astro-0752cf3688eaac535ceda1ebcd22ccaf20b2171f.zip |
Prevent React hook call warnings when used with MDX (#8324)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/mdx/test/mdx-plus-react.test.js')
-rw-r--r-- | packages/integrations/mdx/test/mdx-plus-react.test.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-plus-react.test.js b/packages/integrations/mdx/test/mdx-plus-react.test.js index 22d7ca0e7..904c58b14 100644 --- a/packages/integrations/mdx/test/mdx-plus-react.test.js +++ b/packages/integrations/mdx/test/mdx-plus-react.test.js @@ -2,13 +2,27 @@ import { expect } from 'chai'; import { parseHTML } from 'linkedom'; import { loadFixture } from '../../../astro/test/test-utils.js'; +function hookError() { + const error = console.error; + const errors = []; + console.error = function(...args) { + errors.push(args); + }; + return () => { + console.error = error; + return errors; + }; +} + describe('MDX and React', () => { let fixture; + let unhook; before(async () => { fixture = await loadFixture({ root: new URL('./fixtures/mdx-plus-react/', import.meta.url), }); + unhook = hookError(); await fixture.build(); }); @@ -20,4 +34,16 @@ describe('MDX and React', () => { expect(p.textContent).to.equal('Hello world'); }); + + it('mdx renders fine', async () => { + const html = await fixture.readFile('/post/index.html'); + const { document } = parseHTML(html); + const h = document.querySelector('#testing'); + expect(h.textContent).to.equal('Testing'); + }); + + it('does not get a invalid hook call warning', () => { + const errors = unhook(); + expect(errors).to.have.a.lengthOf(0); + }); }); |