mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
added unit tests for lib/markdown
This commit is contained in:
48
tests/fixtures/markdowns.js
vendored
Normal file
48
tests/fixtures/markdowns.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
const basic = `
|
||||
# Welcome to Boostnote!
|
||||
## Click here to edit markdown :wave:
|
||||
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/L0qNPLsvmyM" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
## Docs :memo:
|
||||
- [Boostnote | Boost your happiness, productivity and creativity.](https://hackernoon.com/boostnote-boost-your-happiness-productivity-and-creativity-315034efeebe)
|
||||
- [Cloud Syncing & Backups](https://github.com/BoostIO/Boostnote/wiki/Cloud-Syncing-and-Backup)
|
||||
- [How to sync your data across Desktop and Mobile apps](https://github.com/BoostIO/Boostnote/wiki/Sync-Data-Across-Desktop-and-Mobile-apps)
|
||||
- [Convert data from **Evernote** to Boostnote.](https://github.com/BoostIO/Boostnote/wiki/Evernote)
|
||||
- [Keyboard Shortcuts](https://github.com/BoostIO/Boostnote/wiki/Keyboard-Shortcuts)
|
||||
- [Keymaps in Editor mode](https://github.com/BoostIO/Boostnote/wiki/Keymaps-in-Editor-mode)
|
||||
- [How to set syntax highlight in Snippet note](https://github.com/BoostIO/Boostnote/wiki/Syntax-Highlighting)
|
||||
|
||||
---
|
||||
|
||||
## Article Archive :books:
|
||||
- [Reddit English](http://bit.ly/2mOJPu7)
|
||||
- [Reddit Spanish](https://www.reddit.com/r/boostnote_es/)
|
||||
- [Reddit Chinese](https://www.reddit.com/r/boostnote_cn/)
|
||||
- [Reddit Japanese](https://www.reddit.com/r/boostnote_jp/)
|
||||
|
||||
---
|
||||
|
||||
## Community :beers:
|
||||
- [GitHub](http://bit.ly/2AWWzkD)
|
||||
- [Twitter](http://bit.ly/2z8BUJZ)
|
||||
- [Facebook Group](http://bit.ly/2jcca8t)
|
||||
`
|
||||
|
||||
const codeblock = `
|
||||
\`\`\`js:filename.js:2
|
||||
var project = 'boostnote';
|
||||
\`\`\`
|
||||
`
|
||||
|
||||
const katex = `
|
||||
$$
|
||||
c = \pm\sqrt{a^2 + b^2}
|
||||
$$
|
||||
`
|
||||
|
||||
export default {
|
||||
basic,
|
||||
codeblock,
|
||||
katex
|
||||
}
|
||||
22
tests/lib/markdown-test.js
Normal file
22
tests/lib/markdown-test.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import test from 'ava'
|
||||
import Markdown from 'browser/lib/markdown'
|
||||
import markdownFixtures from '../fixtures/markdowns'
|
||||
|
||||
// basic markdown instance which meant to be used in every test cases.
|
||||
// To test markdown options, initialize a new instance in your test case
|
||||
const md = new Markdown()
|
||||
|
||||
test('Markdown.render() should renders markdown correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.basic)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders codeblock correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.codeblock)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders KaTeX correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.katex)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
54
tests/lib/snapshots/markdown-test.js.md
Normal file
54
tests/lib/snapshots/markdown-test.js.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Snapshot report for `tests/lib/markdown-test.js`
|
||||
|
||||
The actual snapshot is saved in `markdown-test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://ava.li).
|
||||
|
||||
## Markdown.render() should renders KaTeX correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<span class="katex-display"><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>c</mi><mo>=</mo><mi>p</mi><mi>m</mi><mi>s</mi><mi>q</mi><mi>r</mi><mi>t</mi><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mrow></mrow><annotation encoding="application/x-tex">c = pmsqrt{a^2 + b^2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8641079999999999em;"></span><span class="strut bottom" style="height:1.0585479999999998em;vertical-align:-0.19444em;"></span><span class="base"><span class="mord mathit">c</span><span class="mord rule" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mord rule" style="margin-right:0.2777777777777778em;"></span><span class="mord mathit">p</span><span class="mord mathit">m</span><span class="mord mathit">s</span><span class="mord mathit" style="margin-right:0.03588em;">q</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">t</span><span class="mord"><span class="mord"><span class="mord mathit">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641079999999999em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord rule" style="margin-right:0.2222222222222222em;"></span><span class="mbin">+</span><span class="mord rule" style="margin-right:0.2222222222222222em;"></span><span class="mord"><span class="mord mathit">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641079999999999em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span>␊
|
||||
`
|
||||
|
||||
## Markdown.render() should renders codeblock correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<pre class="code CodeMirror"><span class="filename">filename.js</span><span class="lineNumber CodeMirror-gutters"><span class="CodeMirror-linenumber">2</span></span><code class="js">var project = 'boostnote';␊
|
||||
</code></pre>␊
|
||||
`
|
||||
|
||||
## Markdown.render() should renders markdown correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<h1 data-line="1" id="Welcome-to-Boostnote">Welcome to Boostnote!</h1>␊
|
||||
<h2 data-line="2" id="Click-here-to-edit-markdown-%F0%9F%91%8B">Click here to edit markdown 👋</h2>␊
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/L0qNPLsvmyM" frameborder="0" allowfullscreen></iframe>␊
|
||||
<h2 data-line="6" id="Docs-%F0%9F%93%9D">Docs 📝</h2>␊
|
||||
<ul>␊
|
||||
<li><a href="https://hackernoon.com/boostnote-boost-your-happiness-productivity-and-creativity-315034efeebe">Boostnote | Boost your happiness, productivity and creativity.</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Cloud-Syncing-and-Backup">Cloud Syncing & Backups</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Sync-Data-Across-Desktop-and-Mobile-apps">How to sync your data across Desktop and Mobile apps</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Evernote">Convert data from <strong>Evernote</strong> to Boostnote.</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Keyboard-Shortcuts">Keyboard Shortcuts</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Keymaps-in-Editor-mode">Keymaps in Editor mode</a></li>␊
|
||||
<li><a href="https://github.com/BoostIO/Boostnote/wiki/Syntax-Highlighting">How to set syntax highlight in Snippet note</a></li>␊
|
||||
</ul>␊
|
||||
<hr />␊
|
||||
<h2 data-line="17" id="Article-Archive-%F0%9F%93%9A">Article Archive 📚</h2>␊
|
||||
<ul>␊
|
||||
<li><a href="http://bit.ly/2mOJPu7">Reddit English</a></li>␊
|
||||
<li><a href="https://www.reddit.com/r/boostnote_es/">Reddit Spanish</a></li>␊
|
||||
<li><a href="https://www.reddit.com/r/boostnote_cn/">Reddit Chinese</a></li>␊
|
||||
<li><a href="https://www.reddit.com/r/boostnote_jp/">Reddit Japanese</a></li>␊
|
||||
</ul>␊
|
||||
<hr />␊
|
||||
<h2 data-line="25" id="Community-%F0%9F%8D%BB">Community 🍻</h2>␊
|
||||
<ul>␊
|
||||
<li><a href="http://bit.ly/2AWWzkD">GitHub</a></li>␊
|
||||
<li><a href="http://bit.ly/2z8BUJZ">Twitter</a></li>␊
|
||||
<li><a href="http://bit.ly/2jcca8t">Facebook Group</a></li>␊
|
||||
</ul>␊
|
||||
`
|
||||
BIN
tests/lib/snapshots/markdown-test.js.snap
Normal file
BIN
tests/lib/snapshots/markdown-test.js.snap
Normal file
Binary file not shown.
Reference in New Issue
Block a user