11'use strict'
22
33const test = require ( 'tape' )
4+ const anchorMarkdownHeadings = require ( '../../scripts/plugins/anchor-markdown-headings' )
45
56test ( 'anchorMarkdownHeadings' , ( t ) => {
6- const anchorMarkdownHeadings = require ( '../../scripts/plugins/anchor-markdown-headings' )
7+ t . plan ( 6 )
78
8- t . plan ( 5 )
9- t . test ( 'correctly pharses markdown heading without links' , ( t ) => {
9+ t . test ( 'correctly parses markdown heading without links' , ( t ) => {
1010 const text = 'Simple title'
1111 const level = 1
1212 const raw = 'Simple title'
@@ -19,7 +19,7 @@ test('anchorMarkdownHeadings', (t) => {
1919 t . equal ( output , expected )
2020 } )
2121
22- t . test ( 'correctly pharses markdown heading with a single link' , ( t ) => {
22+ t . test ( 'correctly parses markdown heading with a single link' , ( t ) => {
2323 const text = 'Title with <a href="#">link</a>'
2424 const level = 3
2525 const raw = 'Title with [link](#)'
@@ -33,7 +33,7 @@ test('anchorMarkdownHeadings', (t) => {
3333 t . equal ( output , expected )
3434 } )
3535
36- t . test ( 'correctly pharses markdown heading with multiple links' , ( t ) => {
36+ t . test ( 'correctly parses markdown heading with multiple links' , ( t ) => {
3737 const text = 'a <a href="b">b</a> c<a href="d">d</a>e'
3838 const level = 2
3939 const raw = 'a [b](b) c[d](d)e'
@@ -60,7 +60,7 @@ test('anchorMarkdownHeadings', (t) => {
6060 t . equal ( output , expected )
6161 } )
6262
63- t . test ( 'correctly pharses markdown heading with non-English characters' , ( t ) => {
63+ t . test ( 'correctly parses markdown heading with non-English characters' , ( t ) => {
6464 const text = '这是<a href="b">链接</a>的<a href="d">测试!</a>'
6565 const level = 2
6666 const raw = '<!-- anchor-With-Non-English-Characters -->这是[链接](b)c[测试!](d)'
@@ -69,6 +69,18 @@ test('anchorMarkdownHeadings', (t) => {
6969 '这是<a href="b">链接</a>的<a href="d">测试!</a>' +
7070 '<a name="anchor-with-non-english-characters" class="anchor" href="#anchor-with-non-english-characters" ' +
7171 'aria-labelledby="header-anchor-with-non-english-characters"></a></h2>'
72+
73+ t . plan ( 1 )
74+ t . equal ( output , expected )
75+ } )
76+
77+ t . test ( 'does not generate empty anchors' , ( t ) => {
78+ const text = 'إنضم إلينا'
79+ const level = 2
80+ const raw = 'إنضم إلينا'
81+ const output = anchorMarkdownHeadings ( text , level , raw )
82+ const expected = '<h2>إنضم إلينا</h2>'
83+
7284 t . plan ( 1 )
7385 t . equal ( output , expected )
7486 } )
0 commit comments