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

Attachment management should only become active on cloning notes if the note was of type MARKDOWN_NOTE -> No Stacktraces otherwise!

This commit is contained in:
ehhc
2018-05-23 19:24:03 +02:00
parent cd6233a3d7
commit bfcf349ffe
2 changed files with 35 additions and 15 deletions

View File

@@ -396,8 +396,8 @@ it('should test that moveAttachments returns a correct modified content version'
})
it('should test that cloneAttachments modifies the content of the new note correctly', function () {
const oldNote = {key: 'oldNoteKey', content: 'oldNoteContent', storage: 'storageKey'}
const newNote = {key: 'newNoteKey', content: 'oldNoteContent', storage: 'storageKey'}
const oldNote = {key: 'oldNoteKey', content: 'oldNoteContent', storage: 'storageKey', type: 'MARKDOWN_NOTE'}
const newNote = {key: 'newNoteKey', content: 'oldNoteContent', storage: 'storageKey', type: 'MARKDOWN_NOTE'}
const testInput =
'Test input' +
'![' + systemUnderTest.STORAGE_FOLDER_PLACEHOLDER + path.sep + oldNote.key + path.sep + 'image.jpg](imageName}) \n' +
@@ -418,8 +418,8 @@ it('should test that cloneAttachments finds all attachments and copies them to t
const storagePathNew = 'storagePathNew'
const dummyStorageOld = {path: storagePathOld}
const dummyStorageNew = {path: storagePathNew}
const oldNote = {key: 'oldNoteKey', content: 'oldNoteContent', storage: 'storageKeyOldNote'}
const newNote = {key: 'newNoteKey', content: 'oldNoteContent', storage: 'storageKeyNewNote'}
const oldNote = {key: 'oldNoteKey', content: 'oldNoteContent', storage: 'storageKeyOldNote', type: 'MARKDOWN_NOTE'}
const newNote = {key: 'newNoteKey', content: 'oldNoteContent', storage: 'storageKeyNewNote', type: 'MARKDOWN_NOTE'}
const testInput =
'Test input' +
'![' + systemUnderTest.STORAGE_FOLDER_PLACEHOLDER + path.sep + oldNote.key + path.sep + 'image.jpg](imageName}) \n' +
@@ -451,3 +451,19 @@ it('should test that cloneAttachments finds all attachments and copies them to t
expect(sander.copyFileSync.mock.calls[1][0]).toBe(pathAttachmentTwoFrom)
expect(copyFileSyncResp.to.mock.calls[1][0]).toBe(pathAttachmentTwoTo)
})
it('should test that cloneAttachments finds all attachments and copies them to the new location', function () {
const oldNote = {key: 'oldNoteKey', content: 'oldNoteContent', storage: 'storageKeyOldNote', type: 'SOMETHING_ELSE'}
const newNote = {key: 'newNoteKey', content: 'oldNoteContent', storage: 'storageKeyNewNote', type: 'SOMETHING_ELSE'}
const testInput = 'Test input'
oldNote.content = testInput
newNote.content = testInput
sander.copyFileSync = jest.fn()
findStorage.findStorage = jest.fn()
systemUnderTest.cloneAttachments(oldNote, newNote)
expect(findStorage.findStorage).not.toHaveBeenCalled()
expect(sander.copyFileSync).not.toHaveBeenCalled()
})