File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ import { MarkdownParser } from '../src/classes/markdown' ;
2+ import { promises as fs } from 'fs' ;
3+ import * as path from 'path' ;
4+ import { fileURLToPath } from 'url' ;
5+
6+ const __filename = fileURLToPath ( import . meta. url ) ;
7+ const __dirname = path . dirname ( __filename ) ;
8+
9+ describe ( 'Line Endings' , ( ) => {
10+ const mixedLineEndingsContent = '# Test\n\n## Heading 1\r\n### Heading 2\r' ;
11+ const expectedLinks = [
12+ '- [Heading 1](#heading-1)' ,
13+ ' - [Heading 2](#heading-2)' ,
14+ ] ;
15+
16+ it ( 'should handle mixed line endings' , async ( ) => {
17+ const tempDir = await fs . mkdtemp ( path . join ( __dirname , 'temp-' ) ) ;
18+ const tempFile = path . join ( tempDir , 'test.md' ) ;
19+ await fs . writeFile ( tempFile , mixedLineEndingsContent ) ;
20+ const parser = new MarkdownParser ( tempFile ) ;
21+ const links = await parser . parse ( ) ;
22+ expect ( links ) . toEqual ( expectedLinks ) ;
23+ await fs . rm ( tempDir , { recursive : true , force : true } ) ;
24+ } ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments