mirror of
				https://github.com/theoludwig/markdownlint-rule-relative-links.git
				synced 2025-11-01 00:49:07 +01:00 
			
		
		
		
	feat: validate relative links fragments
Similar to https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md Fixes #2 BREAKING CHANGE: Validate links fragments in relative links
This commit is contained in:
		
							
								
								
									
										37
									
								
								test/utils.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								test/utils.test.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
const test = require('node:test')
 | 
			
		||||
const assert = require('node:assert/strict')
 | 
			
		||||
 | 
			
		||||
const {
 | 
			
		||||
  convertHeadingToHTMLFragment,
 | 
			
		||||
  getMarkdownHeadings
 | 
			
		||||
} = require('../src/utils.js')
 | 
			
		||||
 | 
			
		||||
test('utils', async (t) => {
 | 
			
		||||
  await t.test('convertHeadingToHTMLFragment', async () => {
 | 
			
		||||
    assert.strictEqual(
 | 
			
		||||
      convertHeadingToHTMLFragment('Valid Fragments'),
 | 
			
		||||
      '#valid-fragments'
 | 
			
		||||
    )
 | 
			
		||||
    assert.strictEqual(
 | 
			
		||||
      convertHeadingToHTMLFragment('Valid Heading With Underscores _'),
 | 
			
		||||
      '#valid-heading-with-underscores-_'
 | 
			
		||||
    )
 | 
			
		||||
    assert.strictEqual(
 | 
			
		||||
      convertHeadingToHTMLFragment(
 | 
			
		||||
        `Valid Heading With Quotes ' And Double Quotes "`
 | 
			
		||||
      ),
 | 
			
		||||
      '#valid-heading-with-quotes--and-double-quotes-'
 | 
			
		||||
    )
 | 
			
		||||
    assert.strictEqual(
 | 
			
		||||
      convertHeadingToHTMLFragment('🚀 Valid Heading With Emoji'),
 | 
			
		||||
      '#-valid-heading-with-emoji'
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  await t.test('getMarkdownHeadings', async () => {
 | 
			
		||||
    assert.deepStrictEqual(
 | 
			
		||||
      getMarkdownHeadings('# Hello\n\n## World\n\n## Hello, world!\n'),
 | 
			
		||||
      ['Hello', 'World', 'Hello, world!']
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user