diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index 980bf859..4eec7ca6 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -388,7 +388,7 @@ function removeStorageAndNoteReferences (input, noteKey) { /** * @description replace all :storage references with given destination folder. - * @param input Input in which the references should be deleted + * @param input Input in which the references should be replaced * @param noteKey Key of the current note * @param destinationFolder Destination folder of the attachements * @returns {String} Input without the references diff --git a/tests/dataApi/attachmentManagement.test.js b/tests/dataApi/attachmentManagement.test.js index a4cc8082..4b40e0d2 100644 --- a/tests/dataApi/attachmentManagement.test.js +++ b/tests/dataApi/attachmentManagement.test.js @@ -334,6 +334,64 @@ it('should make sure that "removeStorageAndNoteReferences" works with markdown c expect(actual).toEqual(expectedOutput) }) +it('should replace the all ":storage" references', function () { + const storageFolder = systemUnderTest.DESTINATION_FOLDER + const noteKey = 'noteKey' + const testInput = + '\n' + + ' \n' + + ' //header\n' + + ' \n' + + ' \n' + + '

Headline

\n' + + '

\n' + + ' dummyImage.png\n' + + '

\n' + + '

\n' + + ' dummyPDF.pdf\n' + + '

\n' + + '

\n' + + ' dummyImage2.jpg\n' + + '

\n' + + ' \n' + + '' + const expectedOutput = + '\n' + + ' \n' + + ' //header\n' + + ' \n' + + ' \n' + + '

Headline

\n' + + '

\n' + + ' dummyImage.png\n' + + '

\n' + + '

\n' + + ' dummyPDF.pdf\n' + + '

\n' + + '

\n' + + ' dummyImage2.jpg\n' + + '

\n' + + ' \n' + + '' + const actual = systemUnderTest.replaceStorageReferences(testInput, noteKey) + expect(actual).toEqual(expectedOutput) +}) + +it('should make sure that "replaceStorageReferences" works with markdown content as well', function () { + const noteKey = 'noteKey' + const testInput = + 'Test input' + + '![' + systemUnderTest.STORAGE_FOLDER_PLACEHOLDER + path.sep + noteKey + path.sep + 'image.jpg](imageName}) \n' + + '[' + systemUnderTest.STORAGE_FOLDER_PLACEHOLDER + path.sep + noteKey + path.sep + 'pdf.pdf](pdf})' + + const expectedOutput = + 'Test input' + + '![' + systemUnderTest.DESTINATION_FOLDER + path.sep + 'image.jpg](imageName}) \n' + + '[' + systemUnderTest.DESTINATION_FOLDER + path.sep + 'pdf.pdf](pdf})' + const actual = systemUnderTest.replaceStorageReferences(testInput, noteKey) + expect(actual).toEqual(expectedOutput) +}) + it('should delete the correct attachment folder if a note is deleted', function () { const dummyStorage = {path: 'dummyStoragePath'} const storageKey = 'storageKey'