@@ -19,8 +19,13 @@ test('toHast', async function (t) {
1919
2020 await t . test ( 'should throw on non-nodes' , async function ( ) {
2121 assert . throws ( function ( ) {
22- // @ts -expect-error: check that non-node children throw at runtime.
23- toHast ( { type : 'bar' , children : [ true ] } )
22+ toHast ( {
23+ type : 'paragraph' ,
24+ children : [
25+ // @ts -expect-error: check that non-node children throw at runtime.
26+ true
27+ ]
28+ } )
2429 } )
2530 } )
2631
@@ -255,10 +260,8 @@ test('toHast', async function (t) {
255260 const customMdast = {
256261 type : 'paragraph' ,
257262 children : [
258- // @ts -expect-error: check how a custom literal is handled.
259- { type : 'a' , value : 'alpha' } ,
260- // @ts -expect-error: check how a custom parent is handled.
261- { type : 'b' , children : [ { type : 'image' , url : 'bravo' } ] } ,
263+ { type : 'alpha' , value : 'alpha' } ,
264+ { type : 'bravo' , children : [ { type : 'image' , url : 'bravo' } ] } ,
262265 { type : 'text' , value : 'charlie' }
263266 ]
264267 }
@@ -297,29 +300,21 @@ test('toHast', async function (t) {
297300 await t . test ( 'should support `unknownHandler`' , async function ( ) {
298301 assert . deepEqual (
299302 toHast ( customMdast , {
300- // To do: improved test.
301- // @ts -expect-error `hast` expected, but this returns unknown mdast nodes.
302- unknownHandler ( _ , /** @type {Nodes } */ node ) {
303- return node
303+ unknownHandler ( ) {
304+ return { type : 'text' , value : 'unknown!' }
304305 }
305306 } ) ,
306- h ( 'p' , [
307- { type : 'a' , value : 'alpha' } ,
308- // To do: register custom?
309- // @ts -expect-error: custom.
310- { type : 'b' , children : [ { type : 'image' , url : 'bravo' } ] } ,
311- 'charlie'
312- ] )
307+ h ( 'p' , [ 'unknown!' , 'unknown!' , 'charlie' ] )
313308 )
314309 } )
315310
316311 await t . test ( 'should support `passThrough`' , async function ( ) {
317312 assert . deepEqual (
318- toHast ( customMdast , { passThrough : [ 'a ' , 'b ' ] } ) ,
313+ toHast ( customMdast , { passThrough : [ 'alpha ' , 'bravo ' ] } ) ,
319314 h ( 'p' , [
320- { type : 'a ' , value : 'alpha' } ,
321- // @ts -expect-error: custom .
322- { type : 'b ' , children : [ h ( 'img' , { src : 'bravo' } ) ] } ,
315+ { type : 'alpha ' , value : 'alpha' } ,
316+ // @ts -expect-error: to do: remove when `hastscript` is released .
317+ { type : 'bravo ' , children : [ h ( 'img' , { src : 'bravo' } ) ] } ,
323318 'charlie'
324319 ] )
325320 )
0 commit comments