@@ -10,8 +10,7 @@ var vfile = require('to-vfile')
1010var Latin = require ( 'parse-latin' )
1111var Dutch = require ( 'parse-dutch' )
1212var English = require ( 'parse-english' )
13- var negate = require ( 'negate' )
14- var hidden = require ( 'is-hidden' )
13+ var isHidden = require ( 'is-hidden' )
1514var toNlcst = require ( '..' )
1615
1716test ( 'mdast-util-to-nlcst' , function ( t ) {
@@ -133,31 +132,41 @@ test('mdast-util-to-nlcst', function (t) {
133132
134133test ( 'Fixtures' , function ( t ) {
135134 var base = path . join ( __dirname , 'fixtures' )
135+ var files = fs . readdirSync ( base )
136+ var index = - 1
137+ var name
138+ var input
139+ var expected
140+ var mdast
141+ var options
136142
137- fs . readdirSync ( base )
138- . filter ( negate ( hidden ) )
139- . forEach ( function ( name ) {
140- var input = vfile . readSync ( path . join ( base , name , 'input.md' ) )
141- var expected = JSON . parse (
142- vfile . readSync ( path . join ( base , name , 'output.json' ) )
143- )
144- var options
145-
146- try {
147- options = JSON . parse (
148- vfile . readSync ( path . join ( base , name , 'options.json' ) )
149- )
150- } catch ( _ ) { }
143+ while ( ++ index < files . length ) {
144+ name = files [ index ]
151145
152- var mdast = remark ( )
153- . use ( options && options . useRemarkGfm ? gfm : [ ] )
154- . use ( options && options . useRemarkFrontmatter ? frontmatter : [ ] )
155- . parse ( input )
146+ if ( isHidden ( name ) ) continue
156147
157- var actual = toNlcst ( mdast , input , Latin , options )
148+ input = vfile . readSync ( path . join ( base , name , 'input.md' ) )
149+ expected = JSON . parse ( vfile . readSync ( path . join ( base , name , 'output.json' ) ) )
158150
159- t . deepEqual ( actual , expected , 'should work on `' + name + '`' )
160- } )
151+ try {
152+ options = JSON . parse (
153+ vfile . readSync ( path . join ( base , name , 'options.json' ) )
154+ )
155+ } catch ( _ ) {
156+ options = null
157+ }
158+
159+ mdast = remark ( )
160+ . use ( options && options . useRemarkGfm ? gfm : [ ] )
161+ . use ( options && options . useRemarkFrontmatter ? frontmatter : [ ] )
162+ . parse ( input )
163+
164+ t . deepEqual (
165+ toNlcst ( mdast , input , Latin , options ) ,
166+ expected ,
167+ 'should work on `' + name + '`'
168+ )
169+ }
161170
162171 t . end ( )
163172} )
0 commit comments