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.
vitepress/__tests__/node/utils/deeplyParseHeader.spec.ts

35 lines
988 B

import { test, expect } from 'vitest'
import { deeplyParseHeader } from 'node/utils/parseHeader'
test('deeplyParseHeader', () => {
const asserts: Record<string, string> = {
3 years ago
// remove tail html
'# `H1` <Comp></Comp>': '# H1',
'# *H1* <Comp/>': '# H1',
3 years ago
// reserve code-wrapped tail html
'# `H1` `<Comp></Comp>`': '# H1 <Comp></Comp>',
'# *H1* `<Comp/>`': '# H1 <Comp/>',
3 years ago
// remove leading html
'# <Comp></Comp> `H1`': '# H1',
'# <Comp/> *H1*': '# H1',
3 years ago
// reserve code-wrapped leading html
'# `<Comp></Comp>` `H1`': '# <Comp></Comp> H1',
'# `<Comp/>` *H1*': '# <Comp/> H1',
3 years ago
// remove middle html
'# `H1` <Comp></Comp> `H2`': '# H1 H2',
'# `H1` <Comp/> `H2`': '# H1 H2',
3 years ago
// reserve middle html
'# `H1` `<Comp></Comp>` `H2`': '# H1 <Comp></Comp> H2',
'# `H1` `<Comp/>` `H2`': '# H1 <Comp/> H2'
}
Object.keys(asserts).forEach((input) => {
expect(deeplyParseHeader(input)).toBe(asserts[input])
})
})