Skip to content

Commit

Permalink
Add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-zhukov committed Mar 26, 2022
1 parent 280124f commit cd9b32f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/mdx/test/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,28 @@ test('jsx', async () => {
'}',
''
].join('\n'),
'should always inject _missingMdxReference checks'
)

assert.equal(
String(compileSync('<a render={(x) => <x.y />} />', {jsx: true})),
[
'/*@jsxRuntime automatic @jsxImportSource react*/',
'function MDXContent(props = {}) {',
' const {wrapper: MDXLayout} = props.components || ({});',
' return MDXLayout ? <MDXLayout {...props}><_createMdxContent /></MDXLayout> : _createMdxContent();',
' function _createMdxContent() {',
' if (!x) _missingMdxReference("x", false);',
' if (!x.y) _missingMdxReference("x.y", true);',
' return <a render={x => <x.y />} />;',
' }',
'}',
'export default MDXContent;',
'function _missingMdxReference(id, component) {',
' throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it.");',
'}',
''
].join('\n'),
'should serialize members inside expressions'
)

Expand Down

0 comments on commit cd9b32f

Please sign in to comment.