-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix: Handling invalid Markdown bold (#190)
* Update utils.ts * Update index.tsx * Update utils.ts * Create utils.test.ts * Update index.tsx * Update type.ts * Update type.ts * Update utils.ts * Update utils.ts --------- Co-authored-by: CanisMinor <[email protected]>
- Loading branch information
1 parent
f9cb396
commit 3a21228
Showing
3 changed files
with
71 additions
and
4 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
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,32 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { fixMarkdownBold } from './utils'; | ||
|
||
describe('fixMarkdownBold', () => { | ||
it('should add space after closing bold markers if needed', () => { | ||
expect(fixMarkdownBold('**123:**456')).toBe('**123:** 456'); | ||
expect(fixMarkdownBold('**bold text**')).toBe('**bold text**'); | ||
expect(fixMarkdownBold('**bold text** and more')).toBe('**bold text** and more'); | ||
expect(fixMarkdownBold('**123**456')).toBe('**123**456'); | ||
}); | ||
|
||
it('should handle multiple bold sections', () => { | ||
expect(fixMarkdownBold('**bold1** **bold2**')).toBe('**bold1** **bold2**'); | ||
expect(fixMarkdownBold('**123:**456**789:**123')).toBe('**123:** 456**789:** 123'); | ||
}); | ||
|
||
it('should not affect text without bold markers', () => { | ||
expect(fixMarkdownBold('normal text')).toBe('normal text'); | ||
}); | ||
|
||
it('should not affect empty strings', () => { | ||
expect(fixMarkdownBold('')).toBe(''); | ||
}); | ||
|
||
it('should handle odd number of asterisks', () => { | ||
expect(fixMarkdownBold('*text* *')).toBe('*text* *'); | ||
}); | ||
|
||
it('should handle asterisks within words', () => { | ||
expect(fixMarkdownBold('t*e*st')).toBe('t*e*st'); | ||
}); | ||
}); |
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