@@ -26,39 +26,44 @@ test('mdast-util-toc', function (t) {
2626
2727test ( 'Fixtures' , function ( t ) {
2828 var root = join ( __dirname , 'fixtures' )
29-
30- fs . readdirSync ( root )
31- . filter ( function ( filepath ) {
32- return filepath . indexOf ( '.' ) !== 0
33- } )
34- . forEach ( function ( name ) {
35- var input = fs . readFileSync ( join ( root , name , 'input.md' ) )
36- var output = fs . readFileSync ( join ( root , name , 'output.json' ) )
37- var config = { }
38- var expected = JSON . parse ( output )
39- var actual
40- var processor = unified ( )
41-
42- try {
43- config = JSON . parse ( fs . readFileSync ( join ( root , name , 'config.json' ) ) )
44- } catch ( _ ) { }
45-
46- processor . use ( remarkParse ) . use ( remarkGfm )
47-
48- if ( config . useRemarkFootnotes ) {
49- processor . use ( remarkFootnotes , { inlineNotes : true } )
50- }
51-
52- if ( config . useRemarkAttr ) {
53- // To do: add remark attr back when it’s updated for the new parser.
54- // `processor.use(remarkAttr)`
55- return
56- }
57-
58- actual = toc ( processor . parse ( input ) , config )
59-
60- t . deepEqual ( actual , expected , name )
61- } )
29+ var files = fs . readdirSync ( root )
30+ var index = - 1
31+ var name
32+ var input
33+ var expected
34+ var actual
35+ var config
36+ var processor
37+
38+ while ( ++ index < files . length ) {
39+ name = files [ index ]
40+
41+ if ( name . indexOf ( '.' ) === 0 ) continue
42+
43+ input = fs . readFileSync ( join ( root , name , 'input.md' ) )
44+ expected = JSON . parse ( fs . readFileSync ( join ( root , name , 'output.json' ) ) )
45+ processor = unified ( ) . use ( remarkParse ) . use ( remarkGfm )
46+
47+ try {
48+ config = JSON . parse ( fs . readFileSync ( join ( root , name , 'config.json' ) ) )
49+ } catch ( _ ) {
50+ config = { }
51+ }
52+
53+ if ( config . useRemarkFootnotes ) {
54+ processor . use ( remarkFootnotes , { inlineNotes : true } )
55+ }
56+
57+ if ( config . useRemarkAttr ) {
58+ // To do: add remark attr back when it’s updated for the new parser.
59+ // `processor.use(remarkAttr)`
60+ continue
61+ }
62+
63+ actual = toc ( processor . parse ( input ) , config )
64+
65+ t . deepEqual ( actual , expected , name )
66+ }
6267
6368 t . end ( )
6469} )
0 commit comments