-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(plugin-md-power): add
audioReader
unit tests (#401)
- Loading branch information
1 parent
2e28989
commit b5c7b05
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
plugins/plugin-md-power/__test__/__snapshots__/audioReader.spec.ts.snap
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,20 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`artPlayerPlugin > should not work 1`] = ` | ||
"<p>@[audioReader @<a href="">audioReader</a></p> | ||
<p>@[audioReader]xxx</p> | ||
<p>@[ audioReader](123456</p> | ||
<p>@[audioReader]((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()</p> | ||
<p>@<a href="/xxx.mp3"> audioReader</a> xxx</p> | ||
<p>@<a href="xxx.mp3">audioReader</a> xxx</p> | ||
<p>@[audioReader](javascript:alert(1)) xxx</p> | ||
" | ||
`; | ||
|
||
exports[`artPlayerPlugin > should work 1`] = ` | ||
"<p><AudioReader src="/xxx.mp3"></AudioReader> <AudioReader src="/xxx.mp3"></AudioReader></p> | ||
<p><AudioReader src="/xxx.mp3">title</AudioReader></p> | ||
<p><AudioReader src="/xxx.mp3" :start-time="0" :end-time="99" :volume="0.55"></AudioReader></p> | ||
<p>xxx <AudioReader src="/xxx.mp3" type="audio/mp3"></AudioReader> xxx</p> | ||
" | ||
`; |
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,48 @@ | ||
import MarkdownIt from 'markdown-it' | ||
import { describe, expect, it } from 'vitest' | ||
import { audioReaderPlugin } from '../src/node/embed/audio/reader.js' | ||
|
||
function createMarkdown() { | ||
return MarkdownIt().use((md) => { | ||
md.block.ruler.before('code', 'import_code', () => false) | ||
md.renderer.rules.import_code = () => '' | ||
}).use(audioReaderPlugin) | ||
} | ||
|
||
describe('artPlayerPlugin', () => { | ||
it('should work', () => { | ||
const md = createMarkdown() | ||
const code = `\ | ||
@[audioReader](/xxx.mp3) @[audioReader](/xxx.mp3) | ||
@[audioReader autoplay title="title"](/xxx.mp3) | ||
@[audioReader autoplay start-time="0" end-time="99" volume="0.55"](/xxx.mp3) | ||
xxx @[audioReader type="audio/mp3"](/xxx.mp3) xxx | ||
` | ||
|
||
expect(md.render(code)).toMatchSnapshot() | ||
}) | ||
|
||
it('should not work', () => { | ||
const md = createMarkdown() | ||
const code = `\ | ||
@[audioReader @[audioReader]() | ||
@[audioReader]xxx | ||
@[ audioReader](123456 | ||
@[audioReader]((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((() | ||
@[ audioReader](/xxx.mp3) xxx | ||
@[audioReader]( xxx.mp3) xxx | ||
@[audioReader](javascript:alert(1)) xxx | ||
` | ||
|
||
expect(md.render(code)).toMatchSnapshot() | ||
}) | ||
}) |
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