未验证 提交 844b56a0 编写于 作者: B Billyyyyy3320 提交者: GitHub

test($shared-utils): complete existed tests of shared-utils (#2366)

* test($shared-utils): cover more cases for unescapeHtml

* test($shared-utils): cover more cases for fileToPath

* test($shared-utils): cover more cases for parseHeaders
上级 394c4f66
import fileToPath from '../src/fileToPath'
test('fileToPath', () => {
test('should return dirname of the path when it is index file ', () => {
const asserts: Record<string, string> = {
'README.md': '/',
'README.vue': '/',
'foo/README.md': '/foo/',
'foo.md': '/foo.html',
'foo/bar.md': '/foo/bar.html'
'foo/README.vue': '/foo/'
}
Object.keys(asserts).forEach(file => {
expect(fileToPath(file)).toBe(asserts[file])
})
})
test('should return a path with .html suffix', () => {
const asserts: Record<string, string> = {
'foo.md': '/foo.html',
'foo.vue': '/foo.html',
'foo/bar.md': '/foo/bar.html',
'foo/bar.vue': '/foo/bar.html'
}
Object.keys(asserts).forEach(file => {
expect(fileToPath(file)).toBe(asserts[file])
})
})
......@@ -2,8 +2,8 @@ import parseHeaders from '../src/parseHeaders'
describe('parseHeaders', () => {
test('should unescape html', () => {
const input = '&lt;div&gt;'
expect(parseHeaders(input)).toBe('<div>')
const input = `&lt;div :id=&quot;&#39;app&#39;&quot;&gt;`
expect(parseHeaders(input)).toBe(`<div :id="'app'">`)
})
test('should remove markdown tokens correctly', () => {
......
import unescapeHtml from '../src/unescapeHtml'
test('should unescape html', () => {
const input = '&lt;div&gt;'
expect(unescapeHtml(input)).toBe('<div>')
const input = `&lt;div :id=&quot;&#39;app&#39;&quot;&gt;`
expect(unescapeHtml(input)).toBe(`<div :id="'app'">`)
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册