@@ -33,6 +33,9 @@ const assertTransformerYieldsDocument = (transformer, expected) => {
3333 new JSDOM ( expected ) . window . document ,
3434 ) ;
3535
36+ // Reset the transformer between the 2 calls to avoid leakages in the tests
37+ transformer . reset ( ) ;
38+
3639 assertEquivalentNode (
3740 transformer . getNode ( 'section' ) ,
3841 new JSDOM ( `<section>${ expected } </section>` ) . window . document . body . firstChild ,
@@ -48,7 +51,35 @@ describe('Test MDAST to VDOM Transformation', () => {
4851 const mdast = fs . readJSONSync ( path . resolve ( __dirname , 'fixtures' , 'simple.json' ) ) ;
4952 assertTransformerYieldsDocument (
5053 new VDOM ( mdast , action . secrets ) ,
51- '<h1>Hello World</h1>' ,
54+ '<h1 id="hello-world">Hello World</h1>' ,
55+ ) ;
56+ } ) ;
57+
58+ it ( 'Headings MDAST Conversion' , ( ) => {
59+ const mdast = fs . readJSONSync ( path . resolve ( __dirname , 'fixtures' , 'heading-ids.json' ) ) ;
60+ assertTransformerYieldsDocument (
61+ new VDOM ( mdast , action . secrets ) , `
62+ <h1 id="foo">Foo</h1>
63+ <h2 id="bar">Bar</h2>
64+ <h3 id="baz">Baz</h1>
65+ <h2 id="qux">Qux</h2>
66+ <h3 id="bar-1">Bar</h3>
67+ <h4 id="bar-1-1">Bar-1</h4>` ,
68+ ) ;
69+ } ) ;
70+
71+ it ( 'Sections MDAST Conversion' , ( ) => {
72+ const mdast = fs . readJSONSync ( path . resolve ( __dirname , 'fixtures' , 'headings.json' ) ) ;
73+ assertTransformerYieldsDocument (
74+ new VDOM ( mdast , action . secrets ) , `
75+ <h1 id="heading-1-double-underline">Heading 1 (double-underline)</h1>
76+ <h2 id="heading-2-single-underline">Heading 2 (single-underline)</h2>
77+ <h1 id="heading-1">Heading 1</h1>
78+ <h2 id="heading-2">Heading 2</h2>
79+ <h3 id="heading-3">Heading 3</h3>
80+ <h4 id="heading-4">Heading 4</h4>
81+ <h5 id="heading-5">Heading 5</h5>
82+ <h6 id="heading-6">Heading 6</h6>` ,
5283 ) ;
5384 } ) ;
5485
0 commit comments