-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for mdx + React usage (#4174)
* Add test for mdx + React usage * Add a changeset Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
- Loading branch information
1 parent
14d27c1
commit 8eb3a8c
Showing
8 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@astrojs/mdx': patch | ||
'@astrojs/react': patch | ||
--- | ||
|
||
Allows using React with automatic imports alongside MDX |
6 changes: 6 additions & 0 deletions
6
packages/integrations/mdx/test/fixtures/mdx-plus-react/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import mdx from '@astrojs/mdx'; | ||
import react from '@astrojs/react'; | ||
|
||
export default { | ||
integrations: [react(), mdx()] | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/integrations/mdx/test/fixtures/mdx-plus-react/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/mdx-plus-react", | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/mdx": "workspace:*", | ||
"@astrojs/react": "workspace:*" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/integrations/mdx/test/fixtures/mdx-plus-react/src/components/Component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Component = () => { | ||
return <p>Hello world</p>; | ||
}; | ||
|
||
export default Component; |
11 changes: 11 additions & 0 deletions
11
packages/integrations/mdx/test/fixtures/mdx-plus-react/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
import Component from "../components/Component.jsx"; | ||
--- | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<Component /> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import mdx from '@astrojs/mdx'; | ||
|
||
import { expect } from 'chai'; | ||
import { parseHTML } from 'linkedom'; | ||
import { loadFixture } from '../../../astro/test/test-utils.js'; | ||
|
||
describe('MDX and React', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: new URL('./fixtures/mdx-plus-react/', import.meta.url), | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('can be used in the same project', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const { document } = parseHTML(html); | ||
|
||
const p = document.querySelector('p'); | ||
|
||
expect(p.textContent).to.equal('Hello world'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.