Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/@vuepress/shared-utils/__tests__/fileToPath.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
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])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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'">`)
})