-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1678 from rayou/add-unit-tests-for-lib-markdown
Added unit tests for lib/markdown
- Loading branch information
Showing
11 changed files
with
1,442 additions
and
453 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
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,57 @@ | ||
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} | ||
$$ | ||
` | ||
|
||
const checkboxes = ` | ||
- [ ] Unchecked | ||
- [x] Checked | ||
` | ||
|
||
const smartQuotes = 'This is a "QUOTE".' | ||
|
||
export default { | ||
basic, | ||
codeblock, | ||
katex, | ||
checkboxes, | ||
smartQuotes | ||
} |
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,9 @@ | ||
import browserEnv from 'browser-env' | ||
browserEnv(['window', 'document']) | ||
|
||
window.localStorage = { | ||
// polyfill | ||
getItem () { | ||
return '{}' | ||
} | ||
} |
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 mock from 'mock-require' | ||
|
||
const noop = () => {} | ||
|
||
mock('electron', { | ||
remote: { | ||
app: { | ||
getAppPath: noop | ||
} | ||
} | ||
}) |
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,36 @@ | ||
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) | ||
}) | ||
|
||
test('Markdown.render() should renders checkboxes', t => { | ||
const rendered = md.render(markdownFixtures.checkboxes) | ||
t.snapshot(rendered) | ||
}) | ||
|
||
test('Markdown.render() should text with quotes correctly', t => { | ||
const renderedSmartQuotes = md.render(markdownFixtures.smartQuotes) | ||
t.snapshot(renderedSmartQuotes) | ||
|
||
const newmd = new Markdown({ typographer: false }) | ||
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes) | ||
t.snapshot(renderedNonSmartQuotes) | ||
}) |
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,76 @@ | ||
# 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 checkboxes | ||
|
||
> Snapshot 1 | ||
`<ul>␊ | ||
<li class="taskListItem"><input type="checkbox" id="checkbox-2" /> Unchecked</li>␊ | ||
<li class="taskListItem"><input type="checkbox" checked id="checkbox-3" /> Checked</li>␊ | ||
</ul>␊ | ||
` | ||
|
||
## 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>␊ | ||
` | ||
|
||
## Markdown.render() should text with quotes correctly | ||
|
||
> Snapshot 1 | ||
`<p data-line="0">This is a “QUOTE”.</p>␊ | ||
` | ||
|
||
> Snapshot 2 | ||
`<p data-line="0">This is a "QUOTE".</p>␊ | ||
` |
Binary file not shown.
Oops, something went wrong.