mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
4 years ago
|
import { parseHeader } from 'node/utils/parseHeader'
|
||
|
|
||
|
describe('parseHeader', () => {
|
||
|
test('should unescape html', () => {
|
||
|
const input = `<div :id="'app'">`
|
||
|
expect(parseHeader(input)).toBe(`<div :id="'app'">`)
|
||
|
})
|
||
|
|
||
|
test('should remove markdown tokens correctly', () => {
|
||
|
const asserts: Record<string, string> = {
|
||
|
// vuepress #238
|
||
|
'[vue](vuejs.org)': 'vue',
|
||
|
'`vue`': 'vue',
|
||
|
'*vue*': 'vue',
|
||
|
'**vue**': 'vue',
|
||
|
'***vue***': 'vue',
|
||
|
_vue_: 'vue',
|
||
|
'\\_vue\\_': '_vue_',
|
||
|
'\\*vue\\*': '*vue*',
|
||
|
'\\!vue\\!': '!vue!',
|
||
|
|
||
|
// vuepress #2688
|
||
|
'[vue](vuejs.org) / [vue](vuejs.org)': 'vue / vue',
|
||
|
'[\\<ins>](vuejs.org)': '<ins>',
|
||
|
|
||
|
// vuepress #564 For multiple markdown tokens
|
||
|
'`a` and `b`': 'a and b',
|
||
|
'***bold and italic***': 'bold and italic',
|
||
|
'**bold** and *italic*': 'bold and italic',
|
||
|
|
||
|
// escaping \$
|
||
|
'\\$vue': '$vue'
|
||
|
}
|
||
|
Object.keys(asserts).forEach((input) => {
|
||
|
expect(parseHeader(input)).toBe(asserts[input])
|
||
|
})
|
||
|
})
|
||
|
})
|