-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added unit tests for lib/markdown #1678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Rokt33r
merged 10 commits into
BoostIO:master
from
rayou:add-unit-tests-for-lib-markdown
Mar 18, 2018
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a1e9c5
removed katex script tag from main.html, use import instead
rayou 3cba71b
upgraded ava to 0.25.0
rayou bbcd674
updated lib/consts to access electron remote.app only when in product…
rayou 1af3744
added unit tests for lib/markdown
rayou b5cb209
added browser testing support to ava
rayou f72b4f0
added unit test for checkbox markdown syntax
rayou 8bf5d02
Revert "updated lib/consts to access electron remote.app only when in…
rayou c147e0a
mocked electron in ava unit tests
rayou 03d11b7
Merge remote-tracking branch 'upstream/master' into add-unit-tests-fo…
rayou 1dd7644
added smart quotes unit test for lib/markdown
rayou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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', { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added mock electron. |
||
| remote: { | ||
| app: { | ||
| getAppPath: noop | ||
| } | ||
| } | ||
| }) | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -29,5 +29,5 @@ test('RcParser should return a json object', t => { | |
| }) | ||
|
|
||
| function filePath (filename) { | ||
| return path.join('boostnoterc', filename) | ||
| return path.join(`${__dirname}/boostnoterc`, filename) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. breaking change in ava v0.17.0 |
||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upgraded to 0.25.0 for snapshot support