mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-11 00:36:26 +00:00
resolved conflict
This commit is contained in:
169
tests/lib/__snapshots__/markdown.test.js.snap
Normal file
169
tests/lib/__snapshots__/markdown.test.js.snap
Normal file
@@ -0,0 +1,169 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Markdown.render() should render PlantUML Ditaa correctly 1`] = `
|
||||
"<img src=\\"http://www.plantuml.com/plantuml/png/SoWkIImgISaiIKpaqjQ50cq51GLj93Q2mrMZ00NQO3cmHX3RJW4cKmDI4v9QKQ805a8nfyObCp6zA34NgCObFxiqDpMl1AIcHj4tCJqpLH5i18evG52TKbk3B8og1kmC0cvMKB1Im0NYkA2ckMRcANWabgQbvYau5YMbPfP0p4UOWmcqkHnIyrB0GG00\\" alt=\\"uml diagram\\" />
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render PlantUML Gantt correctly 1`] = `
|
||||
"<img src=\\"http://www.plantuml.com/plantuml/svg/SoWkIImgIK_CAodXYWueoY_9BwaiI5L8IItEJC-BLSX9B2ufLZ0qLKX9h2pcYWv9BIvHA82fWaiRu906crsia5YYW6cqUh52QbuAbmEG0DiE0000\\" alt=\\"uml diagram\\" />
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render PlantUML MindMaps correctly 1`] = `
|
||||
"<img src=\\"http://www.plantuml.com/plantuml/svg/JOzD3e8m44Rtd6BMtNW192IM5I29HEDsAbKdeLD2MvNRIsjCMCsRlFd9LpgFipV4Wy4f4o2r8kHC23Yhm3wi9A0X3XzeYNrgwx1H6wvb1KTjqtRJoYhMtexBSAqJUescwoEUq4tn3xp9Fm7XfUS5HiiFO3Gw7SjT4QUCkkKxLy2-WAvl3rkrtEclBdOCXcnMwZN7ByiN\\" alt=\\"uml diagram\\" />
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render PlantUML Umls correctly 1`] = `
|
||||
"<img src=\\"http://www.plantuml.com/plantuml/svg/LOzD2eCm44RtESMtj0jx01V5E_G4Gvngo2_912gbTsz4LBfylCV7p5Y4ibJlbEENG2AocHV1P39hCJ6eOar8bCaZaROqyrDMnzWqXTcn8YqnGzSYqNC-q76sweoW5zOsLi57uMpHz-WESslY0jmVw1AjdaE30IPeLoVUceLTslrL3-2tS9ZA_qZRtm_vgh7PzkOF\\" alt=\\"uml diagram\\" />
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render PlantUML WBS correctly 1`] = `
|
||||
"<img src=\\"http://www.plantuml.com/plantuml/svg/ZP2_JiD03CRtFeNdRF04fR140gdGeREv-z8plVYYimFYxSabKbaxsR9-ylTdRyxLVpvjrz5XDb6OqR6MqEPRYSXPz4BdmsdNTVJAiuP4da1JBLy8lbmxUYxZbE6Wa_CLgUI8IXymS0rf9NeL5yxKDt24EhiKfMDcRNzVO79HcX8RLdvLfZBGa_KtFx2RKcpK7TZ3dTpZfWgskMAZ9jIXr94rW4PubM1RbBZOb-6NtcS9LpgBjlj_1w9QldbPjZHxQ5pg_GC0\\" alt=\\"uml diagram\\" />
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render footnote correctly 1`] = `
|
||||
"<p data-line=\\"1\\"><sup class=\\"footnote-ref\\"><a href=\\"#fn1\\" id=\\"fnref1\\">[1]</a></sup><br />
|
||||
hello-world: <a href=\\"https://github.com/BoostIO/Boostnote/\\">https://github.com/BoostIO/Boostnote/</a></p>
|
||||
<hr class=\\"footnotes-sep\\" />
|
||||
<section class=\\"footnotes\\">
|
||||
<ol class=\\"footnotes-list\\">
|
||||
<li id=\\"fn1\\" class=\\"footnote-item\\"><p>hello-world <a href=\\"#fnref1\\" class=\\"footnote-backref\\">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render line breaks correctly 1`] = `
|
||||
"<p data-line=\\"0\\">This is the first line.<br />
|
||||
This is the second line.</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render line breaks correctly 2`] = `
|
||||
"<p data-line=\\"0\\">This is the first line.
|
||||
This is the second line.</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should render shortcuts correctly 1`] = `
|
||||
"<p data-line=\\"0\\"><kbd>Ctrl</kbd></p>
|
||||
<p data-line=\\"2\\"><kbd>Ctrl</kbd></p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders KaTeX correctly 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=\\"base\\"><span class=\\"strut\\" style=\\"height:0.43056em;vertical-align:0em;\\"></span><span class=\\"mord mathdefault\\">c</span><span class=\\"mspace\\" style=\\"margin-right:0.2777777777777778em;\\"></span><span class=\\"mrel\\">=</span><span class=\\"mspace\\" style=\\"margin-right:0.2777777777777778em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:1.0585479999999998em;vertical-align:-0.19444em;\\"></span><span class=\\"mord mathdefault\\">p</span><span class=\\"mord mathdefault\\">m</span><span class=\\"mord mathdefault\\">s</span><span class=\\"mord mathdefault\\" style=\\"margin-right:0.03588em;\\">q</span><span class=\\"mord mathdefault\\" style=\\"margin-right:0.02778em;\\">r</span><span class=\\"mord mathdefault\\">t</span><span class=\\"mord\\"><span class=\\"mord\\"><span class=\\"mord mathdefault\\">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=\\"mspace\\" style=\\"margin-right:0.2222222222222222em;\\"></span><span class=\\"mbin\\">+</span><span class=\\"mspace\\" style=\\"margin-right:0.2222222222222222em;\\"></span><span class=\\"mord\\"><span class=\\"mord mathdefault\\">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>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders abbrevations correctly 1`] = `
|
||||
"<h2 id=\\"abbr\\" data-line=\\"1\\">abbr</h2>
|
||||
<p data-line=\\"3\\">The <abbr title=\\"Hyper Text Markup Language\\">HTML</abbr> specification<br />
|
||||
is maintained by the <abbr title=\\"World Wide Web Consortium\\">W3C</abbr>.</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders checkboxes 1`] = `
|
||||
"<ul>
|
||||
<li class=\\"taskListItem\\" data-line=\\"1\\"><input type=\\"checkbox\\" id=\\"checkbox-2\\" /> Unchecked</li>
|
||||
<li class=\\"taskListItem checked\\" data-line=\\"2\\"><input type=\\"checkbox\\" checked id=\\"checkbox-3\\" /> Checked</li>
|
||||
</ul>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders codeblock correctly 1`] = `
|
||||
"<pre class=\\"code CodeMirror\\" data-line=\\"1\\">
|
||||
<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>"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders definition lists correctly 1`] = `
|
||||
"<h2 id=\\"definition-list\\" data-line=\\"1\\">definition list</h2>
|
||||
<h3 id=\\"list-1\\" data-line=\\"3\\">list 1</h3>
|
||||
<dl>
|
||||
<dt data-line=\\"5\\">Term 1</dt>
|
||||
<dd data-line=\\"6\\">Definition 1</dd>
|
||||
<dt data-line=\\"8\\">Term 2</dt>
|
||||
<dd data-line=\\"9\\">Definition 2a</dd>
|
||||
<dd data-line=\\"10\\">Definition 2b</dd>
|
||||
</dl>
|
||||
<p data-line=\\"12\\">Term 3<br />
|
||||
~</p>
|
||||
<h3 id=\\"list-2\\" data-line=\\"16\\">list 2</h3>
|
||||
<dl>
|
||||
<dt data-line=\\"18\\">Term 1</dt>
|
||||
<dd data-line=\\"20\\">
|
||||
<p data-line=\\"20\\">Definition 1</p>
|
||||
</dd>
|
||||
<dt data-line=\\"22\\">Term 2 with <em>inline markup</em></dt>
|
||||
<dd data-line=\\"24\\">
|
||||
<p data-line=\\"24\\">Definition 2</p>
|
||||
<pre><code> { some code, part of Definition 2 }
|
||||
</code></pre>
|
||||
<p data-line=\\"28\\">Third paragraph of definition 2.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders markdown correctly 1`] = `
|
||||
"<h1 id=\\"Welcome-to-Boostnote\\" data-line=\\"1\\">Welcome to Boostnote!</h1>
|
||||
<h2 id=\\"Click-here-to-edit-markdown\\" data-line=\\"2\\">Click here to edit markdown 👋</h2>
|
||||
<iframe width=\\"560\\" height=\\"315\\" src=\\"https://www.youtube.com/embed/L0qNPLsvmyM\\" frameborder=\\"0\\" allowfullscreen></iframe>
|
||||
<h2 id=\\"Docs\\" data-line=\\"6\\">Docs 📝</h2>
|
||||
<ul>
|
||||
<li data-line=\\"7\\"><a href=\\"https://hackernoon.com/boostnote-boost-your-happiness-productivity-and-creativity-315034efeebe\\">Boostnote | Boost your happiness, productivity and creativity.</a></li>
|
||||
<li data-line=\\"8\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Cloud-Syncing-and-Backup\\">Cloud Syncing & Backups</a></li>
|
||||
<li data-line=\\"9\\"><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 data-line=\\"10\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Evernote\\">Convert data from <strong>Evernote</strong> to Boostnote.</a></li>
|
||||
<li data-line=\\"11\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Keyboard-Shortcuts\\">Keyboard Shortcuts</a></li>
|
||||
<li data-line=\\"12\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Keymaps-in-Editor-mode\\">Keymaps in Editor mode</a></li>
|
||||
<li data-line=\\"13\\"><a href=\\"https://github.com/BoostIO/Boostnote/wiki/Syntax-Highlighting\\">How to set syntax highlight in Snippet note</a></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h2 id=\\"Article-Archive\\" data-line=\\"17\\">Article Archive 📚</h2>
|
||||
<ul>
|
||||
<li data-line=\\"18\\"><a href=\\"http://bit.ly/2mOJPu7\\">Reddit English</a></li>
|
||||
<li data-line=\\"19\\"><a href=\\"https://www.reddit.com/r/boostnote_es/\\">Reddit Spanish</a></li>
|
||||
<li data-line=\\"20\\"><a href=\\"https://www.reddit.com/r/boostnote_cn/\\">Reddit Chinese</a></li>
|
||||
<li data-line=\\"21\\"><a href=\\"https://www.reddit.com/r/boostnote_jp/\\">Reddit Japanese</a></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h2 id=\\"Community\\" data-line=\\"25\\">Community 🍻</h2>
|
||||
<ul>
|
||||
<li data-line=\\"26\\"><a href=\\"http://bit.ly/2AWWzkD\\">GitHub</a></li>
|
||||
<li data-line=\\"27\\"><a href=\\"http://bit.ly/2z8BUJZ\\">Twitter</a></li>
|
||||
<li data-line=\\"28\\"><a href=\\"http://bit.ly/2jcca8t\\">Facebook Group</a></li>
|
||||
</ul>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders sub correctly 1`] = `
|
||||
"<h2 id=\\"sub\\" data-line=\\"1\\">sub</h2>
|
||||
<p data-line=\\"3\\">H<sub>2</sub>0</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should renders sup correctly 1`] = `
|
||||
"<h2 id=\\"sup\\" data-line=\\"1\\">sup</h2>
|
||||
<p data-line=\\"3\\">29<sup>th</sup></p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should text with quotes correctly 1`] = `
|
||||
"<p data-line=\\"0\\">This is a “QUOTE”.</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Markdown.render() should text with quotes correctly 2`] = `
|
||||
"<p data-line=\\"0\\">This is a "QUOTE".</p>
|
||||
"
|
||||
`;
|
||||
@@ -1,46 +1,45 @@
|
||||
const { escapeHtmlCharacters } = require('browser/lib/utils')
|
||||
const test = require('ava')
|
||||
|
||||
test('escapeHtmlCharacters should return the original string if nothing needed to escape', t => {
|
||||
test('escapeHtmlCharacters should return the original string if nothing needed to escape', () => {
|
||||
const input = 'Nothing to be escaped'
|
||||
const expected = 'Nothing to be escaped'
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should skip code block if that option is enabled', t => {
|
||||
test('escapeHtmlCharacters should skip code block if that option is enabled', () => {
|
||||
const input = ` <no escape>
|
||||
<escapeMe>`
|
||||
const expected = ` <no escape>
|
||||
<escapeMe>`
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', t => {
|
||||
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', () => {
|
||||
const input = '4 spaces &'
|
||||
const expected = '4 spaces &'
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', t => {
|
||||
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', () => {
|
||||
const input = ` <no escape>
|
||||
<escapeMe>`
|
||||
const expected = ` <no escape>
|
||||
<escapeMe>`
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", t => {
|
||||
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", () => {
|
||||
const input = 'Do not escape & or " but do escape &'
|
||||
const expected = 'Do not escape & or " but do escape &'
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should skip char if in code block', t => {
|
||||
test('escapeHtmlCharacters should skip char if in code block', () => {
|
||||
const input = `
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
@@ -62,12 +61,12 @@ dasdasdasd
|
||||
\`\`\`
|
||||
`
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should return the correct result', t => {
|
||||
test('escapeHtmlCharacters should return the correct result', () => {
|
||||
const input = '& < > " \''
|
||||
const expected = '& < > " ''
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
t.is(actual, expected)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
@@ -1,4 +1,3 @@
|
||||
const test = require('ava')
|
||||
const { findStorage } = require('browser/lib/findStorage')
|
||||
|
||||
global.document = require('jsdom').jsdom('<body></body>')
|
||||
@@ -16,20 +15,22 @@ const sander = require('sander')
|
||||
const os = require('os')
|
||||
const storagePath = path.join(os.tmpdir(), 'test/find-storage')
|
||||
|
||||
test.beforeEach(t => {
|
||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||
let storageContext
|
||||
|
||||
beforeEach(() => {
|
||||
storageContext = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([storageContext.cache]))
|
||||
})
|
||||
|
||||
// Unit test
|
||||
test('findStorage() should return a correct storage path(string)', t => {
|
||||
const storageKey = t.context.storage.cache.key
|
||||
test('findStorage() should return a correct storage path(string)', () => {
|
||||
const storageKey = storageContext.cache.key
|
||||
|
||||
t.is(findStorage(storageKey).key, storageKey)
|
||||
t.is(findStorage(storageKey).path, storagePath)
|
||||
expect(findStorage(storageKey).key).toBe(storageKey)
|
||||
expect(findStorage(storageKey).path).toBe(storagePath)
|
||||
})
|
||||
|
||||
test.after(function after() {
|
||||
afterAll(function after() {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
@@ -2,11 +2,10 @@
|
||||
* @fileoverview Unit test for browser/lib/findTitle
|
||||
*/
|
||||
|
||||
const test = require('ava')
|
||||
const { findNoteTitle } = require('browser/lib/findNoteTitle')
|
||||
|
||||
// Unit test
|
||||
test('findNoteTitle#find should return a correct title (string)', t => {
|
||||
test('findNoteTitle#find should return a correct title (string)', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['# hoge\nfuga', '# hoge'],
|
||||
@@ -20,15 +19,11 @@ test('findNoteTitle#find should return a correct title (string)', t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
findNoteTitle(input, false),
|
||||
expected,
|
||||
`Test for find() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(findNoteTitle(input, false)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle=false', t => {
|
||||
test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle=false', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['---\nlayout: test\ntitle: hoge hoge hoge \n---\n# fuga', '# fuga'],
|
||||
@@ -38,15 +33,11 @@ test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
findNoteTitle(input, false),
|
||||
expected,
|
||||
`Test for find() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(findNoteTitle(input, false)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should respect front matter when enableFrontMatterTitle=true', t => {
|
||||
test('findNoteTitle#find should respect front matter when enableFrontMatterTitle=true', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
[
|
||||
@@ -59,15 +50,11 @@ test('findNoteTitle#find should respect front matter when enableFrontMatterTitl
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
findNoteTitle(input, true),
|
||||
expected,
|
||||
`Test for find() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(findNoteTitle(input, true)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should respect frontMatterTitleField when provided', t => {
|
||||
test('findNoteTitle#find should respect frontMatterTitleField when provided', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['---\ntitle: hoge\n---\n# fuga', '# fuga'],
|
||||
@@ -76,10 +63,6 @@ test('findNoteTitle#find should respect frontMatterTitleField when provided', t
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
findNoteTitle(input, true, 'custom'),
|
||||
expected,
|
||||
`Test for find() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(findNoteTitle(input, true, 'custom')).toBe(expected)
|
||||
})
|
||||
})
|
||||
@@ -1,8 +1,7 @@
|
||||
const test = require('ava')
|
||||
const { getTodoStatus } = require('browser/lib/getTodoStatus')
|
||||
|
||||
// Unit test
|
||||
test('getTodoStatus should return a correct hash object', t => {
|
||||
test('getTodoStatus should return a correct hash object', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['', { total: 0, completed: 0 }],
|
||||
@@ -40,15 +39,7 @@ test('getTodoStatus should return a correct hash object', t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
getTodoStatus(input).total,
|
||||
expected.total,
|
||||
`Test for getTodoStatus() input: ${input} expected: ${expected.total}`
|
||||
)
|
||||
t.is(
|
||||
getTodoStatus(input).completed,
|
||||
expected.completed,
|
||||
`Test for getTodoStatus() input: ${input} expected: ${expected.completed}`
|
||||
)
|
||||
expect(getTodoStatus(input).total).toBe(expected.total)
|
||||
expect(getTodoStatus(input).completed).toBe(expected.completed)
|
||||
})
|
||||
})
|
||||
@@ -1,11 +1,10 @@
|
||||
/**
|
||||
* @fileoverview Unit test for browser/lib/htmlTextHelper
|
||||
*/
|
||||
const test = require('ava')
|
||||
const htmlTextHelper = require('browser/lib/htmlTextHelper')
|
||||
|
||||
// Unit test
|
||||
test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
||||
test('htmlTextHelper#decodeEntities should return encoded text (string)', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['<a href=', '<a href='],
|
||||
@@ -21,15 +20,11 @@ test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
htmlTextHelper.decodeEntities(input),
|
||||
expected,
|
||||
`Test for decodeEntities() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(htmlTextHelper.decodeEntities(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('htmlTextHelper#decodeEntities() should return decoded text (string)', t => {
|
||||
test('htmlTextHelper#decodeEntities() should return decoded text (string)', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['<a href=', '<a href='],
|
||||
@@ -44,16 +39,12 @@ test('htmlTextHelper#decodeEntities() should return decoded text (string)', t =>
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
htmlTextHelper.encodeEntities(input),
|
||||
expected,
|
||||
`Test for encodeEntities() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(htmlTextHelper.encodeEntities(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
// Integration test
|
||||
test(t => {
|
||||
test(() => {
|
||||
const testCases = [
|
||||
"var test = 'test'",
|
||||
"<a href='https://boostnote.io'>Boostnote",
|
||||
@@ -63,10 +54,6 @@ test(t => {
|
||||
testCases.forEach(testCase => {
|
||||
const encodedText = htmlTextHelper.encodeEntities(testCase)
|
||||
const decodedText = htmlTextHelper.decodeEntities(encodedText)
|
||||
t.is(
|
||||
decodedText,
|
||||
testCase,
|
||||
'Integration test through encodedText() and decodedText()'
|
||||
)
|
||||
expect(decodedText).toBe(testCase)
|
||||
})
|
||||
})
|
||||
@@ -1,10 +1,9 @@
|
||||
/**
|
||||
* @fileoverview Unit test for browser/lib/markdown
|
||||
*/
|
||||
const test = require('ava')
|
||||
const markdown = require('browser/lib/markdownTextHelper')
|
||||
|
||||
test(t => {
|
||||
test(() => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
// List
|
||||
@@ -42,10 +41,6 @@ test(t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(
|
||||
markdown.strip(input),
|
||||
expected,
|
||||
`Test for strip() input: ${input} expected: ${expected}`
|
||||
)
|
||||
expect(markdown.strip(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
import CodeMirror from 'codemirror'
|
||||
require('codemirror/addon/search/searchcursor.js')
|
||||
const test = require('ava')
|
||||
const markdownToc = require('browser/lib/markdown-toc-generator')
|
||||
const EOL = require('os').EOL
|
||||
|
||||
test(t => {
|
||||
test(() => {
|
||||
/**
|
||||
* Contains array of test cases in format :
|
||||
* [
|
||||
@@ -261,15 +260,11 @@ this is a text
|
||||
const expectedToc = testCase[2].trim()
|
||||
const generatedToc = markdownToc.generate(inputMd)
|
||||
|
||||
t.is(
|
||||
generatedToc,
|
||||
expectedToc,
|
||||
`generate test : ${title} , generated : ${EOL}${generatedToc}, expected : ${EOL}${expectedToc}`
|
||||
)
|
||||
expect(generatedToc).toBe(expectedToc)
|
||||
})
|
||||
})
|
||||
|
||||
test(t => {
|
||||
test(() => {
|
||||
/**
|
||||
* Contains array of test cases in format :
|
||||
* [
|
||||
@@ -667,10 +662,6 @@ this is a level one text
|
||||
editor.setCursor(cursor)
|
||||
markdownToc.generateInEditor(editor)
|
||||
|
||||
t.is(
|
||||
expectedMd,
|
||||
editor.getValue(),
|
||||
`generateInEditor test : ${title} , generated : ${EOL}${editor.getValue()}, expected : ${EOL}${expectedMd}`
|
||||
)
|
||||
expect(expectedMd).toBe(editor.getValue())
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,3 @@
|
||||
import test from 'ava'
|
||||
import Markdown from 'browser/lib/markdown'
|
||||
import markdownFixtures from '../fixtures/markdowns'
|
||||
|
||||
@@ -6,72 +5,72 @@ import markdownFixtures from '../fixtures/markdowns'
|
||||
// To test markdown options, initialize a new instance in your test case
|
||||
const md = new Markdown()
|
||||
|
||||
test('Markdown.render() should renders markdown correctly', t => {
|
||||
test('Markdown.render() should renders markdown correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.basic)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders codeblock correctly', t => {
|
||||
test('Markdown.render() should renders codeblock correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.codeblock)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders KaTeX correctly', t => {
|
||||
test('Markdown.render() should renders KaTeX correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.katex)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders checkboxes', t => {
|
||||
test('Markdown.render() should renders checkboxes', () => {
|
||||
const rendered = md.render(markdownFixtures.checkboxes)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should text with quotes correctly', t => {
|
||||
test('Markdown.render() should text with quotes correctly', () => {
|
||||
const renderedSmartQuotes = md.render(markdownFixtures.smartQuotes)
|
||||
t.snapshot(renderedSmartQuotes)
|
||||
expect(renderedSmartQuotes).toMatchSnapshot()
|
||||
|
||||
const newmd = new Markdown({ typographer: false })
|
||||
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes)
|
||||
t.snapshot(renderedNonSmartQuotes)
|
||||
expect(renderedNonSmartQuotes).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render line breaks correctly', t => {
|
||||
test('Markdown.render() should render line breaks correctly', () => {
|
||||
const renderedBreaks = md.render(markdownFixtures.breaks)
|
||||
t.snapshot(renderedBreaks)
|
||||
expect(renderedBreaks).toMatchSnapshot()
|
||||
|
||||
const newmd = new Markdown({ breaks: false })
|
||||
const renderedNonBreaks = newmd.render(markdownFixtures.breaks)
|
||||
t.snapshot(renderedNonBreaks)
|
||||
expect(renderedNonBreaks).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders abbrevations correctly', t => {
|
||||
test('Markdown.render() should renders abbrevations correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.abbrevations)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders sub correctly', t => {
|
||||
test('Markdown.render() should renders sub correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.subTexts)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders sup correctly', t => {
|
||||
test('Markdown.render() should renders sup correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.supTexts)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders definition lists correctly', t => {
|
||||
test('Markdown.render() should renders definition lists correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.deflists)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render shortcuts correctly', t => {
|
||||
test('Markdown.render() should render shortcuts correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.shortcuts)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render footnote correctly', t => {
|
||||
test('Markdown.render() should render footnote correctly', () => {
|
||||
const rendered = md.render(markdownFixtures.footnote)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should renders [TOC] placholder correctly', t => {
|
||||
@@ -81,25 +80,25 @@ test('Markdown.render() should renders [TOC] placholder correctly', t => {
|
||||
|
||||
test('Markdown.render() should render PlantUML MindMaps correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlMindMap)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Gantt correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlGantt)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML WBS correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlWbs)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Umls correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlUml)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Ditaa correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlDitaa)
|
||||
t.snapshot(rendered)
|
||||
expect(rendered).toMatchSnapshot()
|
||||
})
|
||||
@@ -1,19 +1,17 @@
|
||||
/**
|
||||
* @fileoverview Unit test for browser/lib/normalizeEditorFontFamily
|
||||
*/
|
||||
import test from 'ava'
|
||||
import normalizeEditorFontFamily from '../../browser/lib/normalizeEditorFontFamily'
|
||||
import consts from '../../browser/lib/consts'
|
||||
const defaultEditorFontFamily = consts.DEFAULT_EDITOR_FONT_FAMILY
|
||||
|
||||
test('normalizeEditorFontFamily() should return default font family (string[])', t => {
|
||||
t.is(normalizeEditorFontFamily(), defaultEditorFontFamily.join(', '))
|
||||
test('normalizeEditorFontFamily() should return default font family (string[])', () => {
|
||||
expect(normalizeEditorFontFamily()).toBe(defaultEditorFontFamily.join(', '))
|
||||
})
|
||||
|
||||
test('normalizeEditorFontFamily(["hoge", "huga"]) should return default font family connected with arg.', t => {
|
||||
test('normalizeEditorFontFamily(["hoge", "huga"]) should return default font family connected with arg.', () => {
|
||||
const arg = 'font1, font2'
|
||||
t.is(
|
||||
normalizeEditorFontFamily(arg),
|
||||
expect(normalizeEditorFontFamily(arg)).toBe(
|
||||
`${arg}, ${defaultEditorFontFamily.join(', ')}`
|
||||
)
|
||||
})
|
||||
@@ -1,9 +1,8 @@
|
||||
const test = require('ava')
|
||||
const path = require('path')
|
||||
const { parse } = require('browser/lib/RcParser')
|
||||
|
||||
// Unit test
|
||||
test('RcParser should return a json object', t => {
|
||||
test('RcParser should return a json object', () => {
|
||||
const validJson = {
|
||||
editor: { keyMap: 'vim', switchPreview: 'BLUR', theme: 'monokai' },
|
||||
hotkey: { toggleMain: 'Control + L' },
|
||||
@@ -51,20 +50,12 @@ test('RcParser should return a json object', t => {
|
||||
|
||||
validTestCases.forEach(validTestCase => {
|
||||
const [input, expected] = validTestCase
|
||||
t.is(
|
||||
parse(filePath(input)).editor.keyMap,
|
||||
expected.editor.keyMap,
|
||||
`Test for getTodoStatus() input: ${input} expected: ${expected.keyMap}`
|
||||
)
|
||||
expect(parse(filePath(input)).editor.keyMap).toBe(expected.editor.keyMap)
|
||||
})
|
||||
|
||||
invalidTestCases.forEach(invalidTestCase => {
|
||||
const [input, expected] = invalidTestCase
|
||||
t.is(
|
||||
parse(filePath(input)).editor,
|
||||
expected.editor,
|
||||
`Test for getTodoStatus() input: ${input} expected: ${expected.editor}`
|
||||
)
|
||||
expect(parse(filePath(input)).editor).toBe(expected.editor)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import test from 'ava'
|
||||
import searchFromNotes from 'browser/lib/search'
|
||||
import { dummyNote } from '../fixtures/TestDummy'
|
||||
import _ from 'lodash'
|
||||
@@ -11,7 +10,7 @@ const pickContents = notes =>
|
||||
let notes = []
|
||||
let note1, note2, note3
|
||||
|
||||
test.before(t => {
|
||||
beforeAll(() => {
|
||||
const data1 = { type: 'MARKDOWN_NOTE', content: 'content1', tags: ['tag1'] }
|
||||
const data2 = {
|
||||
type: 'MARKDOWN_NOTE',
|
||||
@@ -27,7 +26,7 @@ test.before(t => {
|
||||
notes = [note1, note2, note3]
|
||||
})
|
||||
|
||||
test('it can find notes by tags and words', t => {
|
||||
test('it can find notes by tags and words', () => {
|
||||
// [input, expected content (Array)]
|
||||
const testWithTags = [
|
||||
['#tag1', [note1.content, note2.content, note3.content]],
|
||||
@@ -49,6 +48,8 @@ test('it can find notes by tags and words', t => {
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expectedContents] = testCase
|
||||
const results = searchFromNotes(notes, input)
|
||||
t.true(_.isEqual(pickContents(results).sort(), expectedContents.sort()))
|
||||
expect(
|
||||
_.isEqual(pickContents(results).sort(), expectedContents.sort())
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -1,58 +1,57 @@
|
||||
import test from 'ava'
|
||||
import slugify from 'browser/lib/slugify'
|
||||
|
||||
test('alphabet and digit', t => {
|
||||
test('alphabet and digit', () => {
|
||||
const upperAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
const lowerAlphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||
const digit = '0123456789'
|
||||
const testCase = upperAlphabet + lowerAlphabet + digit
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === testCase)
|
||||
expect(decodeSlug === testCase).toBe(true)
|
||||
})
|
||||
|
||||
test('should delete unavailable symbols', t => {
|
||||
test('should delete unavailable symbols', () => {
|
||||
const availableSymbols = '_-'
|
||||
const testCase = availableSymbols + "][!'#$%&()*+,./:;<=>?@\\^{|}~`"
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === availableSymbols)
|
||||
expect(decodeSlug === availableSymbols).toBe(true)
|
||||
})
|
||||
|
||||
test('should convert from white spaces between words to hyphens', t => {
|
||||
test('should convert from white spaces between words to hyphens', () => {
|
||||
const testCase = 'This is one'
|
||||
const expectedString = 'This-is-one'
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === expectedString)
|
||||
expect(decodeSlug === expectedString).toBe(true)
|
||||
})
|
||||
|
||||
test('should remove leading white spaces', t => {
|
||||
test('should remove leading white spaces', () => {
|
||||
const testCase = ' This is one'
|
||||
const expectedString = 'This-is-one'
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === expectedString)
|
||||
expect(decodeSlug === expectedString).toBe(true)
|
||||
})
|
||||
|
||||
test('should remove trailing white spaces', t => {
|
||||
test('should remove trailing white spaces', () => {
|
||||
const testCase = 'This is one '
|
||||
const expectedString = 'This-is-one'
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === expectedString)
|
||||
expect(decodeSlug === expectedString).toBe(true)
|
||||
})
|
||||
|
||||
test('2-byte charactor support', t => {
|
||||
test('2-byte charactor support', () => {
|
||||
const testCase = '菠萝芒果テストÀžƁƵ'
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === testCase)
|
||||
expect(decodeSlug === testCase).toBe(true)
|
||||
})
|
||||
|
||||
test('emoji', t => {
|
||||
test('emoji', () => {
|
||||
const testCase = '🌸'
|
||||
const decodeSlug = decodeURI(slugify(testCase))
|
||||
|
||||
t.true(decodeSlug === testCase)
|
||||
expect(decodeSlug === testCase).toBe(true)
|
||||
})
|
||||
Binary file not shown.
Reference in New Issue
Block a user