-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add usemdxcomponents option (#848)
Accepts a `components` opt that it passes into a custom `useMdxComponents` hook.
- Loading branch information
1 parent
b40b8fd
commit 48351a2
Showing
5 changed files
with
2,852 additions
and
1,544 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
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,34 @@ | ||
import { compile, run } from '../../index'; | ||
import { renderToString } from 'react-dom/server'; | ||
import React from 'react'; | ||
|
||
describe('Custom Components', () => { | ||
const Example = () => <div>It works!</div>; | ||
const Composite = () => ( | ||
<> | ||
<div>Does it work?</div> | ||
<Example /> | ||
</> | ||
); | ||
|
||
it('renders custom components', () => { | ||
const doc = ` | ||
<Example /> | ||
`; | ||
const Page = run(compile(doc), { components: { Example } }); | ||
const output = renderToString(<Page />); | ||
|
||
expect(output).toBe('<div data-reactroot="">It works!</div>'); | ||
}); | ||
|
||
it('renders custom components recursively', () => { | ||
const doc = ` | ||
<Composite /> | ||
`; | ||
|
||
const Page = run(compile(doc), { components: { Example, Composite } }); | ||
const output = renderToString(<Page />); | ||
|
||
expect(output).toBe('<div>Does it work?</div><div>It works!</div>'); | ||
}); | ||
}); |
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
Oops, something went wrong.