diff --git a/tests/fixtures/markdowns.js b/tests/fixtures/markdowns.js new file mode 100644 index 00000000..3b535539 --- /dev/null +++ b/tests/fixtures/markdowns.js @@ -0,0 +1,48 @@ +const basic = ` +# Welcome to Boostnote! +## Click here to edit markdown :wave: + + + +## 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 +} diff --git a/tests/lib/markdown-test.js b/tests/lib/markdown-test.js new file mode 100644 index 00000000..5ebe3c09 --- /dev/null +++ b/tests/lib/markdown-test.js @@ -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) +}) diff --git a/tests/lib/snapshots/markdown-test.js.md b/tests/lib/snapshots/markdown-test.js.md new file mode 100644 index 00000000..5c47d494 --- /dev/null +++ b/tests/lib/snapshots/markdown-test.js.md @@ -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 + + `c=pmsqrta2+b2c = pmsqrt{a^2 + b^2}␊ + ` + +## Markdown.render() should renders codeblock correctly + +> Snapshot 1 + + `
filename.js2var project = 'boostnote';␊
+    
␊ + ` + +## Markdown.render() should renders markdown correctly + +> Snapshot 1 + + `

Welcome to Boostnote!

␊ +

Click here to edit markdown 👋

␊ + ␊ +

Docs 📝

␊ + ␊ +
␊ +

Article Archive 📚

␊ + ␊ +
␊ +

Community 🍻

␊ + ␊ + ` diff --git a/tests/lib/snapshots/markdown-test.js.snap b/tests/lib/snapshots/markdown-test.js.snap new file mode 100644 index 00000000..077a20c7 Binary files /dev/null and b/tests/lib/snapshots/markdown-test.js.snap differ