@@ -7,6 +7,7 @@ const path = require('path');
77
88common . globalCheck = false ;
99
10+ const processIncludes = require ( '../../tools/doc/preprocess.js' ) ;
1011const html = require ( '../../tools/doc/html.js' ) . toHTML ;
1112
1213// Test data is a list of objects with two properties.
@@ -55,22 +56,43 @@ const testData = [
5556 '<p>Describe <code>Something</code> in more detail here. ' +
5657 '</p>'
5758 } ,
59+ {
60+ file : path . join ( common . fixturesDir , 'doc_with_includes.md' ) ,
61+ html : '<!-- [start-include:doc_inc_1.md] -->' +
62+ '<p>Look <a href="doc_inc_2.html#doc_inc_2_foobar">here</a>!</p>' +
63+ '<!-- [end-include:doc_inc_1.md] -->' +
64+ '<!-- [start-include:doc_inc_2.md] -->' +
65+ '<h1>foobar<span><a class="mark" href="#doc_inc_2_foobar" ' +
66+ 'id="doc_inc_2_foobar">#</a></span></h1>' +
67+ '<p>I exist and am being linked to.</p>' +
68+ '<!-- [end-include:doc_inc_2.md] -->'
69+ } ,
5870] ;
5971
6072testData . forEach ( function ( item ) {
6173 // Normalize expected data by stripping whitespace
6274 const expected = item . html . replace ( / \s / g, '' ) ;
6375
64- fs . readFile ( item . file , 'utf8' , common . mustCall ( function ( err , input ) {
76+ fs . readFile ( item . file , 'utf8' , common . mustCall ( ( err , input ) => {
6577 assert . ifError ( err ) ;
66- html ( input , 'foo' , 'doc/template.html' ,
67- common . mustCall ( function ( err , output ) {
68- assert . ifError ( err ) ;
78+ processIncludes ( item . file , input , common . mustCall ( ( err , preprocessed ) => {
79+ assert . ifError ( err ) ;
80+
81+ html (
82+ {
83+ input : preprocessed ,
84+ filename : 'foo' ,
85+ template : 'doc/template.html' ,
86+ nodeVersion : process . version ,
87+ } ,
88+ common . mustCall ( ( err , output ) => {
89+ assert . ifError ( err ) ;
6990
70- const actual = output . replace ( / \s / g, '' ) ;
71- // Assert that the input stripped of all whitespace contains the
72- // expected list
73- assert . notEqual ( actual . indexOf ( expected ) , - 1 ) ;
74- } ) ) ;
91+ const actual = output . replace ( / \s / g, '' ) ;
92+ // Assert that the input stripped of all whitespace contains the
93+ // expected list
94+ assert . notEqual ( actual . indexOf ( expected ) , - 1 ) ;
95+ } ) ) ;
96+ } ) ) ;
7597 } ) ) ;
7698} ) ;
0 commit comments