@@ -69,9 +69,7 @@ test('mdast-util-heading-range()', (t) => {
69
69
t ,
70
70
[ '# Fo' , '' , '## Fooooo' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
71
71
/** @type {Options } */
72
- ( value ) => {
73
- return value . toLowerCase ( ) . indexOf ( 'foo' ) === 0
74
- }
72
+ ( value ) => value . toLowerCase ( ) . indexOf ( 'foo' ) === 0
75
73
) ,
76
74
[ '# Fo' , '' , '## Fooooo' , '' , '# Fo' , '' ] . join ( '\n' ) ,
77
75
'should accept a heading as a function'
@@ -139,14 +137,13 @@ test('mdast-util-heading-range()', (t) => {
139
137
)
140
138
141
139
remark ( )
142
- . use ( ( ) => {
143
- return function ( node ) {
144
- const root = /** @type {Root } */ ( node )
145
- headingRange ( root , 'foo' , ( ) => {
146
- return null
147
- } )
148
- }
149
- } )
140
+ . use (
141
+ ( ) =>
142
+ function ( node ) {
143
+ const root = /** @type {Root } */ ( node )
144
+ headingRange ( root , 'foo' , ( ) => null )
145
+ }
146
+ )
150
147
. process ( [ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' ] . join ( '\n' ) , ( error , file ) => {
151
148
t . ifError ( error , 'should not fail (#1)' )
152
149
@@ -158,14 +155,13 @@ test('mdast-util-heading-range()', (t) => {
158
155
} )
159
156
160
157
remark ( )
161
- . use ( ( ) => {
162
- return function ( node ) {
163
- const root = /** @type {Root } */ ( node )
164
- headingRange ( root , 'foo' , ( ) => {
165
- return [ ]
166
- } )
167
- }
168
- } )
158
+ . use (
159
+ ( ) =>
160
+ function ( node ) {
161
+ const root = /** @type {Root } */ ( node )
162
+ headingRange ( root , 'foo' , ( ) => [ ] )
163
+ }
164
+ )
169
165
. process ( [ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' ] . join ( '\n' ) , ( error , file ) => {
170
166
t . ifError ( error , 'should not fail (#2)' )
171
167
@@ -177,14 +173,17 @@ test('mdast-util-heading-range()', (t) => {
177
173
} )
178
174
179
175
remark ( )
180
- . use ( ( ) => {
181
- return function ( node ) {
182
- const root = /** @type {Root } */ ( node )
183
- headingRange ( root , 'foo' , ( start , _ , end ) => {
184
- return [ start , { type : 'thematicBreak' } , end ]
185
- } )
186
- }
187
- } )
176
+ . use (
177
+ ( ) =>
178
+ function ( node ) {
179
+ const root = /** @type {Root } */ ( node )
180
+ headingRange ( root , 'foo' , ( start , _ , end ) => [
181
+ start ,
182
+ { type : 'thematicBreak' } ,
183
+ end
184
+ ] )
185
+ }
186
+ )
188
187
. process (
189
188
[ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' , '## Baz' , '' ] . join ( '\n' ) ,
190
189
( error , file ) => {
@@ -199,15 +198,16 @@ test('mdast-util-heading-range()', (t) => {
199
198
)
200
199
201
200
remark ( )
202
- . use ( ( ) => {
203
- return function ( node ) {
204
- const root = /** @type {Root } */ ( node )
205
- headingRange ( root , 'foo' , ( start , nodes , end ) => {
206
- t . equal ( nodes . length , 3 )
207
- return [ start , ...nodes , end ]
208
- } )
209
- }
210
- } )
201
+ . use (
202
+ ( ) =>
203
+ function ( node ) {
204
+ const root = /** @type {Root } */ ( node )
205
+ headingRange ( root , 'foo' , ( start , nodes , end ) => {
206
+ t . equal ( nodes . length , 3 )
207
+ return [ start , ...nodes , end ]
208
+ } )
209
+ }
210
+ )
211
211
. process (
212
212
[ '# Alpha' , '' , '## Foo' , '' , 'one' , '' , 'two' , '' , 'three' , '' ] . join (
213
213
'\n'
@@ -329,17 +329,18 @@ test('mdast-util-heading-range()', (t) => {
329
329
*/
330
330
function process ( t , value , options ) {
331
331
return remark ( )
332
- . use ( ( ) => {
333
- return function ( node ) {
334
- const root = /** @type {Root } */ ( node )
335
- headingRange ( root , options , ( start , _ , end , scope ) => {
336
- t . equal ( typeof scope . start , 'number' )
337
- t . assert ( typeof scope . end === 'number' || scope . end === null )
338
- t . equal ( scope . parent && scope . parent . type , 'root' )
339
- return [ start , end ]
340
- } )
341
- }
342
- } )
332
+ . use (
333
+ ( ) =>
334
+ function ( node ) {
335
+ const root = /** @type {Root } */ ( node )
336
+ headingRange ( root , options , ( start , _ , end , scope ) => {
337
+ t . equal ( typeof scope . start , 'number' )
338
+ t . assert ( typeof scope . end === 'number' || scope . end === null )
339
+ t . equal ( scope . parent && scope . parent . type , 'root' )
340
+ return [ start , end ]
341
+ } )
342
+ }
343
+ )
343
344
. processSync ( value )
344
345
. toString ( )
345
346
}
0 commit comments