@@ -339,6 +339,38 @@ it('should test that deleteAttachmentsNotPresentInNote does not delete reference
339339 expect ( fsUnlinkCallArguments . includes ( path . join ( attachmentFolderPath , dummyFilesInFolder [ 0 ] ) ) ) . toBe ( false )
340340} )
341341
342+ it ( 'should test that deleteAttachmentsNotPresentInNote does nothing if noteKey, storageKey or noteContent was null' , function ( ) {
343+ const noteKey = null
344+ const storageKey = null
345+ const markdownContent = ''
346+
347+ findStorage . findStorage = jest . fn ( )
348+ fs . existsSync = jest . fn ( )
349+ fs . readdir = jest . fn ( )
350+ fs . unlink = jest . fn ( )
351+
352+ systemUnderTest . deleteAttachmentsNotPresentInNote ( markdownContent , storageKey , noteKey )
353+ expect ( fs . existsSync ) . not . toHaveBeenCalled ( )
354+ expect ( fs . readdir ) . not . toHaveBeenCalled ( )
355+ expect ( fs . unlink ) . not . toHaveBeenCalled ( )
356+ } )
357+
358+ it ( 'should test that deleteAttachmentsNotPresentInNote does nothing if noteKey, storageKey or noteContent was undefined' , function ( ) {
359+ const noteKey = undefined
360+ const storageKey = undefined
361+ const markdownContent = ''
362+
363+ findStorage . findStorage = jest . fn ( )
364+ fs . existsSync = jest . fn ( )
365+ fs . readdir = jest . fn ( )
366+ fs . unlink = jest . fn ( )
367+
368+ systemUnderTest . deleteAttachmentsNotPresentInNote ( markdownContent , storageKey , noteKey )
369+ expect ( fs . existsSync ) . not . toHaveBeenCalled ( )
370+ expect ( fs . readdir ) . not . toHaveBeenCalled ( )
371+ expect ( fs . unlink ) . not . toHaveBeenCalled ( )
372+ } )
373+
342374it ( 'should test that moveAttachments moves attachments only if the source folder existed' , function ( ) {
343375 fse . existsSync = jest . fn ( ( ) => false )
344376 fse . moveSync = jest . fn ( )
@@ -403,6 +435,8 @@ it('should test that cloneAttachments modifies the content of the new note corre
403435 ' \n' +
404436 '[' + systemUnderTest . STORAGE_FOLDER_PLACEHOLDER + path . sep + oldNote . key + path . sep + 'pdf.pdf](pdf})'
405437 newNote . content = testInput
438+ findStorage . findStorage = jest . fn ( )
439+ findStorage . findStorage . mockReturnValue ( { path : 'dummyStoragePath' } )
406440
407441 const expectedOutput =
408442 'Test input' +
0 commit comments