-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
234 additions
and
25 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/typedoc-plugin-markdown/src/libs/utils/camel-to-title-case.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,17 @@ | ||
import { camelToTitleCase } from './camel-to-title-case'; | ||
|
||
describe('camelToTitleCase', () => { | ||
it('should convert camel case to title case correctly', () => { | ||
const input = 'camelCaseText'; | ||
const expectedOutput = 'Camel Case Text'; | ||
const result = camelToTitleCase(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle single word correctly', () => { | ||
const input = 'word'; | ||
const expectedOutput = 'Word'; | ||
const result = camelToTitleCase(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/typedoc-plugin-markdown/src/libs/utils/escape-chars.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,11 @@ | ||
import { escapeChars } from './escape-chars'; | ||
|
||
describe('escapeChars', () => { | ||
it('should escape special characters correctly', () => { | ||
const input = 'This is a string with >, <, {, }, _, `, |, [, ], and *'; | ||
const expectedOutput = | ||
'This is a string with \\>, \\<, \\{, \\}, \\_, \\`, \\|, \\[, \\], and \\*'; | ||
const result = escapeChars(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/typedoc-plugin-markdown/src/libs/utils/format-markdown.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,26 @@ | ||
import { formatMarkdown } from './format-markdown'; | ||
|
||
describe('formatMarkdown', () => { | ||
it('should trim content and restrict new lines', () => { | ||
const input = ` | ||
# headline | ||
Paragraph | ||
## headline | ||
`; | ||
const expectedOutput = `# headline | ||
Paragraph | ||
## headline | ||
`; | ||
const result = formatMarkdown(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/typedoc-plugin-markdown/src/libs/utils/format-table-column.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,22 @@ | ||
import { formatTableColumn } from './format-table-column'; | ||
|
||
describe('formatTableColumn', () => { | ||
it('should format table column correctly', () => { | ||
const input = `This is a string with | ||
a newline, | a pipe, and a code block: | ||
\`\`\`ts | ||
const x = 10; | ||
\`\`\``; | ||
const expectedOutput = | ||
'This is a string with<br />a newline, \\| a pipe, and a code block:<br />`const x = 10;`'; | ||
const result = formatTableColumn(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should remove trailing <br /> tags', () => { | ||
const input = 'This is a string with a trailing <br /> tag<br /> '; | ||
const expectedOutput = 'This is a string with a trailing <br /> tag'; | ||
const result = formatTableColumn(input); | ||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/typedoc-plugin-markdown/src/libs/utils/get-file-name-with-extension.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,34 @@ | ||
import path from 'path'; | ||
import { getFileNameWithExtension } from './get-file-name-with-extension'; | ||
|
||
describe('getFileNameWithExtension', () => { | ||
it('should return filename with extension', () => { | ||
const fileName = 'testFile'; | ||
const fileExtension = '.txt'; | ||
const expectedOutput = 'testFile.txt'; | ||
|
||
const result = getFileNameWithExtension(fileName, fileExtension); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle fileExtension without dot', () => { | ||
const fileName = 'testFile'; | ||
const fileExtension = 'txt'; | ||
const expectedOutput = 'testFile.txt'; | ||
|
||
const result = getFileNameWithExtension(fileName, fileExtension); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle fileName with directories', () => { | ||
const fileName = path.join('dir1', 'dir2', 'testFile'); | ||
const fileExtension = 'txt'; | ||
const expectedOutput = path.join('dir1', 'dir2', 'testFile.txt'); | ||
|
||
const result = getFileNameWithExtension(fileName, fileExtension); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
3 changes: 0 additions & 3 deletions
3
packages/typedoc-plugin-markdown/src/libs/utils/get-first-paragraph.ts
This file was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
packages/typedoc-plugin-markdown/src/libs/utils/is-quoted.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,21 @@ | ||
import { isQuoted } from './is-quoted'; | ||
|
||
describe('isQuoted', () => { | ||
it('should return true for quoted strings', () => { | ||
const input = '"This is a quoted string"'; | ||
const expectedOutput = true; | ||
|
||
const result = isQuoted(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should return false for unquoted strings', () => { | ||
const input = 'This is an unquoted string'; | ||
const expectedOutput = false; | ||
|
||
const result = isQuoted(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/typedoc-plugin-markdown/src/libs/utils/remove-first-scoped-directory.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,31 @@ | ||
import path from 'path'; | ||
import { removeFirstScopedDirectory } from './remove-first-scoped-directory'; | ||
|
||
describe('removeFirstScopedDirectory', () => { | ||
it('should remove first scoped directory', () => { | ||
const input = '@scoped/dir1/dir2/file.txt'; | ||
const expectedOutput = `dir1${path.sep}dir2${path.sep}file.txt`; | ||
|
||
const result = removeFirstScopedDirectory(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle string without scoped directory', () => { | ||
const input = 'dir1/dir2/file.txt'; | ||
const expectedOutput = `dir1${path.sep}dir2${path.sep}file.txt`; | ||
|
||
const result = removeFirstScopedDirectory(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle string with multiple scoped directories', () => { | ||
const input = '@scoped/dir1/@scoped/dir2/file.txt'; | ||
const expectedOutput = `dir1${path.sep}@scoped${path.sep}dir2${path.sep}file.txt`; | ||
|
||
const result = removeFirstScopedDirectory(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/typedoc-plugin-markdown/src/libs/utils/remove-line-breaks.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,21 @@ | ||
import { removeLineBreaks } from './remove-line-breaks'; | ||
|
||
describe('removeLineBreaks', () => { | ||
it('should remove line breaks and replace with a single space', () => { | ||
const input = 'This is a string\nwith multiple\n\nline breaks'; | ||
const expectedOutput = 'This is a string with multiple line breaks'; | ||
|
||
const result = removeLineBreaks(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should replace multiple spaces with a single space', () => { | ||
const input = 'This is a string with multiple spaces'; | ||
const expectedOutput = 'This is a string with multiple spaces'; | ||
|
||
const result = removeLineBreaks(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/typedoc-plugin-markdown/src/libs/utils/slugify.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,21 @@ | ||
import { slugify } from './slugify'; | ||
|
||
describe('slugifyUrl', () => { | ||
it('should convert to slug correctly', () => { | ||
const input = ' Type Alias '; | ||
const expectedOutput = 'type-alias'; | ||
|
||
const result = slugify(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle URL with special characters', () => { | ||
const input = 'Reflection!'; | ||
const expectedOutput = 'reflection'; | ||
|
||
const result = slugify(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...in-markdown/src/libs/utils/slugify-url.ts → ...plugin-markdown/src/libs/utils/slugify.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
6 changes: 0 additions & 6 deletions
6
packages/typedoc-plugin-markdown/src/libs/utils/strip-comments.ts
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
packages/typedoc-plugin-markdown/src/libs/utils/un-escape-chars.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,21 @@ | ||
import { unEscapeChars } from './un-escape-chars'; | ||
|
||
describe('unEscapeChars', () => { | ||
it('should unescape characters correctly', () => { | ||
const input = '\\*\\<\\>\\_\\{\\}\\`\\*\\|\\]\\['; | ||
const expectedOutput = '*<>_{}`*|]['; | ||
|
||
const result = unEscapeChars(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
|
||
it('should handle string without escaped characters', () => { | ||
const input = 'This is a string without escaped characters'; | ||
const expectedOutput = 'This is a string without escaped characters'; | ||
|
||
const result = unEscapeChars(input); | ||
|
||
expect(result).toEqual(expectedOutput); | ||
}); | ||
}); |
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
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