forked from vuejs/vuepress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor($shared-utils): migrate to typescript (vuejs#1086)
- Loading branch information
Showing
60 changed files
with
729 additions
and
462 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
packages/@vuepress/shared-utils/lib |
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 |
---|---|---|
|
@@ -4,3 +4,5 @@ node_modules | |
.temp | ||
TODOs.md | ||
vuepress | ||
packages/@vuepress/shared-utils/lib/ | ||
types |
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
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
87 changes: 0 additions & 87 deletions
87
packages/@vuepress/shared-utils/__tests__/deeplyParseHeaders.spec.js
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
packages/@vuepress/shared-utils/__tests__/deeplyParseHeaders.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import deeplyParseHeaders from '../src/deeplyParseHeaders' | ||
|
||
test('deeplyParseHeaders', () => { | ||
const asserts: Record<string, string> = { | ||
// Remove tail html | ||
'# `H1` <Comp></Comp>': '# H1', | ||
'# *H1* <Comp/>': '# H1', | ||
|
||
// Reserve code-wrapped tail html | ||
'# `H1` `<Comp></Comp>`': '# H1 <Comp></Comp>', | ||
'# *H1* `<Comp/>`': '# H1 <Comp/>', | ||
|
||
// Remove leading html | ||
'# <Comp></Comp> `H1`': '# H1', | ||
'# <Comp/> *H1*': '# H1', | ||
|
||
// Reserve code-wrapped leading html | ||
'# `<Comp></Comp>` `H1`': '# <Comp></Comp> H1', | ||
'# `<Comp/>` *H1*': '# <Comp/> H1', | ||
|
||
// Remove middle html | ||
'# `H1` <Comp></Comp> `H2`': '# H1 H2', | ||
'# `H1` <Comp/> `H2`': '# H1 H2', | ||
|
||
// Reserve middle html | ||
'# `H1` `<Comp></Comp>` `H2`': '# H1 <Comp></Comp> H2', | ||
'# `H1` `<Comp/>` `H2`': '# H1 <Comp/> H2' | ||
} | ||
|
||
Object.keys(asserts).forEach(input => { | ||
expect(deeplyParseHeaders(input)).toBe(asserts[input]) | ||
}) | ||
}) |
4 changes: 2 additions & 2 deletions
4
...shared-utils/__tests__/fileToPath.spec.js → ...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
2 changes: 1 addition & 1 deletion
2
...hared-utils/__tests__/isIndexFile.spec.js → ...hared-utils/__tests__/isIndexFile.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
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
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
53 changes: 53 additions & 0 deletions
53
packages/@vuepress/shared-utils/__tests__/removeNonCodeWrappedHTML.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import removeNonCodeWrappedHTML from '../src/removeNonCodeWrappedHTML' | ||
|
||
test('removeNonCodeWrappedHTML', () => { | ||
const asserts: Record<string, string> = { | ||
// Remove tail html | ||
'# H1 <Comp></Comp>': '# H1 ', | ||
'# H1<Comp></Comp>': '# H1', | ||
'# H1 <Comp a="b"></Comp>': '# H1 ', | ||
'# H1<Comp a="b"></Comp>': '# H1', | ||
'# H1 <Comp/>': '# H1 ', | ||
'# H1<Comp/>': '# H1', | ||
'# H1 <Comp a="b"/>': '# H1 ', | ||
'# H1<Comp a="b"/>': '# H1', | ||
|
||
// Reserve code-wrapped tail html | ||
'# H1 `<Comp></Comp>`': '# H1 `<Comp></Comp>`', | ||
'# H1 `<Comp a="b"></Comp>`': '# H1 `<Comp a="b"></Comp>`', | ||
'# H1 `<Comp/>`': '# H1 `<Comp/>`', | ||
'# H1 `<Comp a="b"/>`': '# H1 `<Comp a="b"/>`', | ||
|
||
// Remove leading html | ||
'# <Comp></Comp> H1': '# H1', | ||
'# <Comp></Comp>H1': '# H1', | ||
'# <Comp a="b"></Comp> H1': '# H1', | ||
'# <Comp a="b"></Comp>H1': '# H1', | ||
'# <Comp/> H1': '# H1', | ||
'# <Comp/>H1': '# H1', | ||
'# <Comp a="b"/> H1': '# H1', | ||
'# <Comp a="b"/>H1': '# H1', | ||
|
||
// Reserve code-wrapped leading html | ||
'# `<Comp></Comp>` H1': '# `<Comp></Comp>` H1', | ||
'# `<Comp a="b"></Comp>` H1': '# `<Comp a="b"></Comp>` H1', | ||
'# `<Comp/>` H1': '# `<Comp/>` H1', | ||
'# `<Comp a="b"/>` H1': '# `<Comp a="b"/>` H1', | ||
|
||
// Remove middle html | ||
'# H1 <Comp></Comp> H2': '# H1 H2', | ||
'# H1 <Comp a="b"></Comp> H2': '# H1 H2', | ||
'# H1 <Comp/> H2': '# H1 H2', | ||
'# H1 <Comp a="b"/> H2': '# H1 H2', | ||
|
||
// Reserve code-wrapped middle html | ||
'# H1 `<Comp></Comp>` H2': '# H1 `<Comp></Comp>` H2', | ||
'# H1 `<Comp a="b"></Comp>` H2': '# H1 `<Comp a="b"></Comp>` H2', | ||
'# H1 `<Comp/>` H2': '# H1 `<Comp/>` H2', | ||
'# H1 `<Comp a="b"/>` H2': '# H1 `<Comp a="b"/>` H2' | ||
} | ||
|
||
Object.keys(asserts).forEach(input => { | ||
expect(removeNonCodeWrappedHTML(input)).toBe(asserts[input]) | ||
}) | ||
}) |
2 changes: 1 addition & 1 deletion
2
...ared-utils/__tests__/unescapeHtml.spec.js → ...ared-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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.