5
5
import assert from 'node:assert/strict'
6
6
import { test } from 'node:test'
7
7
import { evaluate } from '@mdx-js/mdx'
8
- import { MDXProvider , useMDXComponents , withMDXComponents } from '@mdx-js/react'
8
+ import { MDXProvider , useMDXComponents } from '@mdx-js/react'
9
9
import React from 'react'
10
10
import * as runtime_ from 'react/jsx-runtime'
11
11
import { renderToString } from 'react-dom/server'
@@ -17,10 +17,8 @@ const runtime = /** @type {RuntimeProduction} */ (
17
17
test ( '@mdx-js/react' , async function ( t ) {
18
18
await t . test ( 'should expose the public api' , async function ( ) {
19
19
assert . deepEqual ( Object . keys ( await import ( '@mdx-js/preact' ) ) . sort ( ) , [
20
- 'MDXContext' ,
21
20
'MDXProvider' ,
22
- 'useMDXComponents' ,
23
- 'withMDXComponents'
21
+ 'useMDXComponents'
24
22
] )
25
23
} )
26
24
@@ -207,45 +205,4 @@ test('@mdx-js/react', async function (t) {
207
205
)
208
206
}
209
207
)
210
-
211
- await t . test ( 'should support `withComponents`' , async function ( ) {
212
- const { default : Content } = await evaluate ( '# hi\n## hello' , {
213
- ...runtime ,
214
- useMDXComponents
215
- } )
216
-
217
- // Unknown props.
218
- // type-coverage:ignore-next-line
219
- const With = withMDXComponents ( function ( props ) {
220
- // Unknown props.
221
- // type-coverage:ignore-next-line
222
- return props . children
223
- } )
224
-
225
- // Bug: this should use the `h2` component too, logically?
226
- // As `withMDXComponents` is deprecated, and it would probably be a breaking
227
- // change, we can just remove it later.
228
- assert . equal (
229
- renderToString (
230
- < MDXProvider
231
- components = { {
232
- h1 ( props ) {
233
- return < h1 style = { { color : 'tomato' } } { ...props } />
234
- }
235
- } }
236
- >
237
- < With
238
- components = { {
239
- h2 ( props ) {
240
- return < h2 style = { { color : 'papayawhip' } } { ...props } />
241
- }
242
- } }
243
- >
244
- < Content />
245
- </ With >
246
- </ MDXProvider >
247
- ) ,
248
- '<h1 style="color:tomato">hi</h1>\n<h2>hello</h2>'
249
- )
250
- } )
251
208
} )
0 commit comments