@@ -191,39 +191,43 @@ describe('Links', () => {
191
191
const inputPath = resolve ( __dirname , './mocks/external-link.md' ) ;
192
192
const input = readFileSync ( inputPath , 'utf8' ) ;
193
193
194
- let result = '' ;
194
+ let link = '' ;
195
195
196
- transformYfm ( input , inputPath , {
196
+ const html = transformYfm ( input , inputPath , {
197
197
transformLink : ( href : string ) => {
198
- href = href . replace ( '.md' , '' ) ;
199
- result = href ;
198
+ link = href ;
200
199
return href ;
201
200
} ,
202
201
} ) ;
203
202
204
- expect ( result ) . toEqual ( 'external-link' ) ;
203
+ expect ( link ) . not . toEqual ( 'https://test.com/' ) ;
204
+ expect ( html ) . toEqual (
205
+ '<p><a href="https://test.com/" target="_blank" rel="noreferrer noopener">Absolute link</a></p>\n' ,
206
+ ) ;
205
207
} ) ;
206
208
207
209
test ( 'Should not call the "transformLink" callback for external link with default path' , ( ) => {
208
210
const inputPath = resolve ( __dirname , './mocks/external-link.md' ) ;
209
211
const input = readFileSync ( inputPath , 'utf8' ) ;
210
212
211
- let result = '' ;
213
+ let link = '' ;
212
214
213
- transformYfm (
215
+ const html = transformYfm (
214
216
input ,
215
217
'mocks/external-link.md' ,
216
218
{
217
219
transformLink : ( href : string ) => {
218
- href = href . replace ( '.md' , '' ) ;
219
- result = href ;
220
+ link = href ;
220
221
return href ;
221
222
} ,
222
223
} ,
223
224
true ,
224
225
) ;
225
226
226
- expect ( result ) . toEqual ( 'mocks/external-link' ) ;
227
+ expect ( link ) . not . toEqual ( 'https://test.com/' ) ;
228
+ expect ( html ) . toEqual (
229
+ '<p><a href="https://test.com/" target="_blank" rel="noreferrer noopener">Absolute link</a></p>\n' ,
230
+ ) ;
227
231
} ) ;
228
232
} ) ;
229
233
} ) ;
0 commit comments