1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Merge branch 'master' into Moving_Note_With_Attachment

This commit is contained in:
Junyoung Choi (Sai)
2018-05-17 01:28:47 +09:00
committed by GitHub
15 changed files with 95 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ jest.mock('unique-slug')
const uniqueSlug = require('unique-slug')
const mdurl = require('mdurl')
const fse = require('fs-extra')
const sander = require('sander')
const systemUnderTest = require('browser/main/lib/dataApi/attachmentManagement')
@@ -262,6 +263,19 @@ it('should remove the all ":storage" and noteKey references', function () {
expect(actual).toEqual(expectedOutput)
})
it('should delete the correct attachment folder if a note is deleted', function () {
const dummyStorage = {path: 'dummyStoragePath'}
const storageKey = 'storageKey'
const noteKey = 'noteKey'
findStorage.findStorage = jest.fn(() => dummyStorage)
sander.rimrafSync = jest.fn()
const expectedPathToBeDeleted = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER, noteKey)
systemUnderTest.deleteAttachmentFolder(storageKey, noteKey)
expect(findStorage.findStorage).toHaveBeenCalledWith(storageKey)
expect(sander.rimrafSync).toHaveBeenCalledWith(expectedPathToBeDeleted)
})
it('should test that deleteAttachmentsNotPresentInNote deletes all unreferenced attachments ', function () {
const dummyStorage = {path: 'dummyStoragePath'}
const noteKey = 'noteKey'

View File

@@ -14,6 +14,8 @@ const sander = require('sander')
const os = require('os')
const CSON = require('@rokt33r/season')
const faker = require('faker')
const fs = require('fs')
const attachmentManagement = require('browser/main/lib/dataApi/attachmentManagement')
const storagePath = path.join(os.tmpdir(), 'test/delete-note')
@@ -42,6 +44,11 @@ test.serial('Delete a note', (t) => {
return Promise.resolve()
.then(function doTest () {
return createNote(storageKey, input1)
.then(function createAttachmentFolder (data) {
fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER))
fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.key))
return data
})
.then(function (data) {
return deleteNote(storageKey, data.key)
})
@@ -52,8 +59,13 @@ test.serial('Delete a note', (t) => {
t.fail('note cson must be deleted.')
} catch (err) {
t.is(err.code, 'ENOENT')
return data
}
})
.then(function assertAttachmentFolderDeleted (data) {
const attachmentFolderPath = path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.noteKey)
t.is(fs.existsSync(attachmentFolderPath), false)
})
})
test.after(function after () {

View File

@@ -48,10 +48,13 @@ const checkboxes = `
const smartQuotes = 'This is a "QUOTE".'
const breaks = 'This is the first line.\nThis is the second line.'
export default {
basic,
codeblock,
katex,
checkboxes,
smartQuotes
smartQuotes,
breaks
}

View File

@@ -34,3 +34,12 @@ test('Markdown.render() should text with quotes correctly', t => {
const renderedNonSmartQuotes = newmd.render(markdownFixtures.smartQuotes)
t.snapshot(renderedNonSmartQuotes)
})
test('Markdown.render() should render line breaks correctly', t => {
const renderedBreaks = md.render(markdownFixtures.breaks)
t.snapshot(renderedBreaks)
const newmd = new Markdown({ breaks: false })
const renderedNonBreaks = newmd.render(markdownFixtures.breaks)
t.snapshot(renderedNonBreaks)
})

View File

@@ -4,6 +4,20 @@ The actual snapshot is saved in `markdown-test.js.snap`.
Generated by [AVA](https://ava.li).
## Markdown.render() should render line breaks correctly
> Snapshot 1
`<p data-line="0">This is the first line.<br />␊
This is the second line.</p>␊
`
> Snapshot 2
`<p data-line="0">This is the first line.␊
This is the second line.</p>␊
`
## Markdown.render() should renders KaTeX correctly
> Snapshot 1