-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for
insertAfterMedia
utility
- Loading branch information
1 parent
84a1571
commit d7b2d47
Showing
2 changed files
with
89 additions
and
1 deletion.
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,85 @@ | ||
import { insertAfterMedia } from './insertAfterMedia'; | ||
|
||
describe('insertAfterMedia', () => { | ||
it('should insert the string after the first line containing content that does not contain solely media', () => { | ||
const markdown = ` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
This line does not contain media. | ||
This line also does not contain media.`; | ||
const inserted = 'Inserted string'; | ||
|
||
const result = insertAfterMedia(markdown, inserted); | ||
|
||
expect(result).toBe(` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
Inserted string | ||
This line does not contain media. | ||
This line also does not contain media.`); | ||
}); | ||
|
||
it('should append the string to the end if there is no line containing content that does not contain solely media', () => { | ||
const markdown = ` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio>`; | ||
const inserted = 'Inserted string'; | ||
|
||
const result = insertAfterMedia(markdown, inserted); | ||
|
||
expect(result).toBe(` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
Inserted string`); | ||
}); | ||
|
||
it('should insert the string before a line containing both media and text content', () => { | ||
const markdown = ` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
 This line contains text and media. | ||
This line does not contain media.`; | ||
const inserted = 'Inserted string'; | ||
|
||
const result = insertAfterMedia(markdown, inserted); | ||
|
||
expect(result).toBe(` | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
Inserted string | ||
 This line contains text and media. | ||
This line does not contain media.`); | ||
}); | ||
|
||
it('should insert the string after a line that contains media wrapped in an alignment block', () => { | ||
const markdown = `::: hljs-center | ||
 | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
::: | ||
::: hljs-center <img src="image.jpg" alt="Image"> ::: | ||
::: hljs-right This line does not contain media. ::: | ||
This line also does not contain media.`; | ||
const inserted = 'Inserted string'; | ||
|
||
const result = insertAfterMedia(markdown, inserted); | ||
|
||
expect(result).toBe(`::: hljs-center | ||
 | ||
<img src="image.jpg" alt="Image"> | ||
<video src="video.mp4"></video> | ||
<audio src="audio.mp3"></audio> | ||
::: | ||
::: hljs-center <img src="image.jpg" alt="Image"> ::: | ||
Inserted string | ||
::: hljs-right This line does not contain media. ::: | ||
This line also does not contain media.`); | ||
}); | ||
}); |
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