mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Merge remote-tracking branch 'origin/master' into feature/toc
Fix conflicts
This commit is contained in:
@@ -578,6 +578,72 @@ it('should test that deleteAttachmentsNotPresentInNote does nothing if noteKey,
|
||||
expect(fs.unlink).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should test that getAttachmentsPathAndStatus return null if noteKey, storageKey or noteContent was undefined', function () {
|
||||
const noteKey = undefined
|
||||
const storageKey = undefined
|
||||
const markdownContent = ''
|
||||
|
||||
const result = systemUnderTest.getAttachmentsPathAndStatus(markdownContent, storageKey, noteKey)
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
it('should test that getAttachmentsPathAndStatus return null if noteKey, storageKey or noteContent was null', function () {
|
||||
const noteKey = null
|
||||
const storageKey = null
|
||||
const markdownContent = ''
|
||||
|
||||
const result = systemUnderTest.getAttachmentsPathAndStatus(markdownContent, storageKey, noteKey)
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
it('should test that getAttachmentsPathAndStatus return the correct path and status for attachments', async function () {
|
||||
const dummyStorage = {path: 'dummyStoragePath'}
|
||||
const noteKey = 'noteKey'
|
||||
const storageKey = 'storageKey'
|
||||
const markdownContent =
|
||||
'Test input' +
|
||||
' \n'
|
||||
const dummyFilesInFolder = ['file1.txt', 'file2.pdf', 'file3.jpg']
|
||||
|
||||
findStorage.findStorage = jest.fn(() => dummyStorage)
|
||||
fs.existsSync = jest.fn(() => true)
|
||||
fs.readdir = jest.fn((paht, callback) => callback(undefined, dummyFilesInFolder))
|
||||
fs.unlink = jest.fn()
|
||||
|
||||
const targetStorage = findStorage.findStorage(storageKey)
|
||||
|
||||
const attachments = await systemUnderTest.getAttachmentsPathAndStatus(markdownContent, storageKey, noteKey)
|
||||
expect(attachments.length).toBe(3)
|
||||
expect(attachments[0].isInUse).toBe(false)
|
||||
expect(attachments[1].isInUse).toBe(true)
|
||||
expect(attachments[2].isInUse).toBe(false)
|
||||
|
||||
expect(attachments[0].path).toBe(
|
||||
path.join(
|
||||
targetStorage.path,
|
||||
systemUnderTest.DESTINATION_FOLDER,
|
||||
noteKey,
|
||||
dummyFilesInFolder[0]
|
||||
)
|
||||
)
|
||||
expect(attachments[1].path).toBe(
|
||||
path.join(
|
||||
targetStorage.path,
|
||||
systemUnderTest.DESTINATION_FOLDER,
|
||||
noteKey,
|
||||
dummyFilesInFolder[1]
|
||||
)
|
||||
)
|
||||
expect(attachments[2].path).toBe(
|
||||
path.join(
|
||||
targetStorage.path,
|
||||
systemUnderTest.DESTINATION_FOLDER,
|
||||
noteKey,
|
||||
dummyFilesInFolder[2]
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('should test that moveAttachments moves attachments only if the source folder existed', function () {
|
||||
fse.existsSync = jest.fn(() => false)
|
||||
fse.moveSync = jest.fn()
|
||||
|
||||
43
tests/dataApi/createNoteFromUrl-test.js
Normal file
43
tests/dataApi/createNoteFromUrl-test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const test = require('ava')
|
||||
const createNoteFromUrl = require('browser/main/lib/dataApi/createNoteFromUrl')
|
||||
|
||||
global.document = require('jsdom').jsdom('<body></body>')
|
||||
global.window = document.defaultView
|
||||
global.navigator = window.navigator
|
||||
|
||||
const Storage = require('dom-storage')
|
||||
const localStorage = window.localStorage = global.localStorage = new Storage(null, { strict: true })
|
||||
const path = require('path')
|
||||
const TestDummy = require('../fixtures/TestDummy')
|
||||
const sander = require('sander')
|
||||
const os = require('os')
|
||||
const CSON = require('@rokt33r/season')
|
||||
|
||||
const storagePath = path.join(os.tmpdir(), 'test/create-note-from-url')
|
||||
|
||||
test.beforeEach((t) => {
|
||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||
})
|
||||
|
||||
test.serial('Create a note from URL', (t) => {
|
||||
const storageKey = t.context.storage.cache.key
|
||||
const folderKey = t.context.storage.json.folders[0].key
|
||||
|
||||
const url = 'https://shapeshed.com/writing-cross-platform-node/'
|
||||
|
||||
return createNoteFromUrl(url, storageKey, folderKey)
|
||||
.then(function assert ({ note }) {
|
||||
t.is(storageKey, note.storage)
|
||||
const jsonData = CSON.readFileSync(path.join(storagePath, 'notes', note.key + '.cson'))
|
||||
|
||||
// Test if saved content is matching the created in memory note
|
||||
t.is(note.content, jsonData.content)
|
||||
t.is(note.tags.length, jsonData.tags.length)
|
||||
})
|
||||
})
|
||||
|
||||
test.after(function after () {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
77
tests/fixtures/markdowns.js
vendored
77
tests/fixtures/markdowns.js
vendored
@@ -117,6 +117,76 @@ const tocPlaceholder = `
|
||||
###$ H4
|
||||
`
|
||||
|
||||
const plantUmlMindMap = `
|
||||
@startmindmap
|
||||
* Debian
|
||||
** Ubuntu
|
||||
*** Linux Mint
|
||||
*** Kubuntu
|
||||
*** Lubuntu
|
||||
*** KDE Neon
|
||||
** LMDE
|
||||
** SolydXK
|
||||
** SteamOS
|
||||
** Raspbian with a very long name
|
||||
*** <s>Raspmbc</s> => OSMC
|
||||
*** <s>Raspyfi</s> => Volumio
|
||||
@endmindmap
|
||||
`
|
||||
|
||||
const plantUmlGantt = `
|
||||
@startgantt
|
||||
[Prototype design] lasts 15 days
|
||||
[Test prototype] lasts 10 days
|
||||
[Test prototype] starts at [Prototype design]'s end
|
||||
@endgantt
|
||||
`
|
||||
|
||||
const plantUmlWbs = `
|
||||
@startwbs
|
||||
* Business Process Modelling WBS
|
||||
** Launch the project
|
||||
*** Complete Stakeholder Research
|
||||
*** Initial Implementation Plan
|
||||
** Design phase
|
||||
*** Model of AsIs Processes Completed
|
||||
**** Model of AsIs Processes Completed1
|
||||
**** Model of AsIs Processes Completed2
|
||||
*** Measure AsIs performance metrics
|
||||
*** Identify Quick Wins
|
||||
** Complete innovate phase
|
||||
@endwbs
|
||||
`
|
||||
|
||||
const plantUmlUml = `
|
||||
@startuml
|
||||
left to right direction
|
||||
skinparam packageStyle rectangle
|
||||
actor customer
|
||||
actor clerk
|
||||
rectangle checkout {
|
||||
customer -- (checkout)
|
||||
(checkout) .> (payment) : include
|
||||
(help) .> (checkout) : extends
|
||||
(checkout) -- clerk
|
||||
}
|
||||
@enduml
|
||||
`
|
||||
|
||||
const plantUmlDitaa = `
|
||||
@startditaa
|
||||
+--------+ +-------+ +-------+
|
||||
| +---+ ditaa +--> | |
|
||||
| Text | +-------+ |Diagram|
|
||||
|Dokument| |!Magie!| | |
|
||||
| {d}| | | | |
|
||||
+---+----+ +-------+ +-------+
|
||||
: ^
|
||||
| Ein Haufen Arbeit |
|
||||
+-------------------------+
|
||||
@endditaa
|
||||
`
|
||||
|
||||
export default {
|
||||
basic,
|
||||
codeblock,
|
||||
@@ -130,5 +200,10 @@ export default {
|
||||
deflists,
|
||||
shortcuts,
|
||||
footnote,
|
||||
tocPlaceholder
|
||||
tocPlaceholder,
|
||||
plantUmlMindMap,
|
||||
plantUmlGantt,
|
||||
plantUmlWbs,
|
||||
plantUmlDitaa,
|
||||
plantUmlUml
|
||||
}
|
||||
|
||||
37
tests/lib/__snapshots__/markdown-remark.test.js.snap
Normal file
37
tests/lib/__snapshots__/markdown-remark.test.js.snap
Normal file
@@ -0,0 +1,37 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Markdown.render() should renders markdown correctly 1`] = `
|
||||
"# 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)
|
||||
"
|
||||
`;
|
||||
@@ -78,3 +78,28 @@ test('Markdown.render() should renders [TOC] placholder correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.tocPlaceholder)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML MindMaps correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlMindMap)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Gantt correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlGantt)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML WBS correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlWbs)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Umls correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlUml)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
test('Markdown.render() should render PlantUML Ditaa correctly', t => {
|
||||
const rendered = md.render(markdownFixtures.plantUmlDitaa)
|
||||
t.snapshot(rendered)
|
||||
})
|
||||
|
||||
@@ -4,6 +4,41 @@ The actual snapshot is saved in `markdown-test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://ava.li).
|
||||
|
||||
## Markdown.render() should render PlantUML Ditaa correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/png/SoWkIImgISaiIKpaqjQ50cq51GLj93Q2mrMZ00NQO3cmHX3RJW4cKmDI4v9QKQ805a8nfyObCp6zA34NgCObFxiqDpMl1AIcHj4tCJqpLH5i18evG52TKbk3B8og1kmC0cvMKB1Im0NYkA2ckMRcANWabgQbvYau5YMbPfP0p4UOWmcqkHnIyrB0GG00" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML Gantt correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/SoWkIImgIK_CAodXYWueoY_9BwaiI5L8IItEJC-BLSX9B2ufLZ0qLKX9h2pcYWv9BIvHA82fWaiRu906crsia5YYW6cqUh52QbuAbmEG0DiE0000" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML MindMaps correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/JOzD3e8m44Rtd6BMtNW192IM5I29HEDsAbKdeLD2MvNRIsjCMCsRlFd9LpgFipV4Wy4f4o2r8kHC23Yhm3wi9A0X3XzeYNrgwx1H6wvb1KTjqtRJoYhMtexBSAqJUescwoEUq4tn3xp9Fm7XfUS5HiiFO3Gw7SjT4QUCkkKxLy2-WAvl3rkrtEclBdOCXcnMwZN7ByiN" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML Umls correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/LOzD2eCm44RtESMtj0jx01V5E_G4Gvngo2_912gbTsz4LBfylCV7p5Y4ibJlbEENG2AocHV1P39hCJ6eOar8bCaZaROqyrDMnzWqXTcn8YqnGzSYqNC-q76sweoW5zOsLi57uMpHz-WESslY0jmVw1AjdaE30IPeLoVUceLTslrL3-2tS9ZA_qZRtm_vgh7PzkOF" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML WBS correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/ZP2_JiD03CRtFeNdRF04fR140gdGeREv-z8plVYYimFYxSabKbaxsR9-ylTdRyxLVpvjrz5XDb6OqR6MqEPRYSXPz4BdmsdNTVJAiuP4da1JBLy8lbmxUYxZbE6Wa_CLgUI8IXymS0rf9NeL5yxKDt24EhiKfMDcRNzVO79HcX8RLdvLfZBGa_KtFx2RKcpK7TZ3dTpZfWgskMAZ9jIXr94rW4PubM1RbBZOb-6NtcS9LpgBjlj_1w9QldbPjZHxQ5pg_GC0" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render footnote correctly
|
||||
|
||||
> Snapshot 1
|
||||
@@ -191,4 +226,39 @@ Generated by [AVA](https://ava.li).
|
||||
> Snapshot 2
|
||||
|
||||
`<p data-line="0">This is a "QUOTE".</p>␊
|
||||
|
||||
|
||||
## Markdown.render() should render PlantUML Ditaa correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/png/SoWkIImgISaiIKpaqjQ50cq51GLj93Q2mrMZ00NQO3cmHX3RJW4cKmDI4v9QKQ805a8nfyObCp6zA34NgCObFxiqDpMl1AIcHj4tCJqpLH5i18evG52TKbk3B8og1kmC0cvMKB1Im0NYkA2ckMRcANWabgQbvYau5YMbPfP0p4UOWmcqkHnIyrB0GG00" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML Gantt correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/SoWkIImgIK_CAodXYWueoY_9BwaiI5L8IItEJC-BLSX9B2ufLZ0qLKX9h2pcYWv9BIvHA82fWaiRu906crsia5YYW6cqUh52QbuAbmEG0DiE0000" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML MindMaps correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/JOzD3e8m44Rtd6BMtNW192IM5I29HEDsAbKdeLD2MvNRIsjCMCsRlFd9LpgFipV4Wy4f4o2r8kHC23Yhm3wi9A0X3XzeYNrgwx1H6wvb1KTjqtRJoYhMtexBSAqJUescwoEUq4tn3xp9Fm7XfUS5HiiFO3Gw7SjT4QUCkkKxLy2-WAvl3rkrtEclBdOCXcnMwZN7ByiN" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML Umls correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/LOzD2eCm44RtESMtj0jx01V5E_G4Gvngo2_912gbTsz4LBfylCV7p5Y4ibJlbEENG2AocHV1P39hCJ6eOar8bCaZaROqyrDMnzWqXTcn8YqnGzSYqNC-q76sweoW5zOsLi57uMpHz-WESslY0jmVw1AjdaE30IPeLoVUceLTslrL3-2tS9ZA_qZRtm_vgh7PzkOF" alt="uml diagram" />␊
|
||||
`
|
||||
|
||||
## Markdown.render() should render PlantUML WBS correctly
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<img src="http://www.plantuml.com/plantuml/svg/ZP2_JiD03CRtFeNdRF04fR140gdGeREv-z8plVYYimFYxSabKbaxsR9-ylTdRyxLVpvjrz5XDb6OqR6MqEPRYSXPz4BdmsdNTVJAiuP4da1JBLy8lbmxUYxZbE6Wa_CLgUI8IXymS0rf9NeL5yxKDt24EhiKfMDcRNzVO79HcX8RLdvLfZBGa_KtFx2RKcpK7TZ3dTpZfWgskMAZ9jIXr94rW4PubM1RbBZOb-6NtcS9LpgBjlj_1w9QldbPjZHxQ5pg_GC0" alt="uml diagram" />␊
|
||||
`
|
||||
Binary file not shown.
Reference in New Issue
Block a user