-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
394c4f6
commit 844b56a
Showing
3 changed files
with
18 additions
and
7 deletions.
There are no files selected for viewing
17 changes: 14 additions & 3 deletions
17
packages/@vuepress/shared-utils/__tests__/fileToPath.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/@vuepress/shared-utils/__tests__/unescapeHtml.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '<div>' | ||
expect(unescapeHtml(input)).toBe('<div>') | ||
const input = `<div :id="'app'">` | ||
expect(unescapeHtml(input)).toBe(`<div :id="'app'">`) | ||
}) | ||
|