@@ -396,9 +396,8 @@ it('should test that moveAttachments returns a correct modified content version'
396
396
} )
397
397
398
398
it ( 'should test that cloneAttachments modifies the content of the new note correctly' , function ( ) {
399
- const storageKey = 'storageKey'
400
- const oldNote = { key : 'oldNoteKey' , content : 'oldNoteContent' }
401
- const newNote = { key : 'newNoteKey' , content : 'oldNoteContent' }
399
+ const oldNote = { key : 'oldNoteKey' , content : 'oldNoteContent' , storage : 'storageKey' }
400
+ const newNote = { key : 'newNoteKey' , content : 'oldNoteContent' , storage : 'storageKey' }
402
401
const testInput =
403
402
'Test input' +
404
403
' \n' +
@@ -409,17 +408,18 @@ it('should test that cloneAttachments modifies the content of the new note corre
409
408
'Test input' +
410
409
' \n' +
411
410
'[' + systemUnderTest . STORAGE_FOLDER_PLACEHOLDER + path . sep + newNote . key + path . sep + 'pdf.pdf](pdf})'
412
- systemUnderTest . cloneAttachments ( storageKey , oldNote , newNote )
411
+ systemUnderTest . cloneAttachments ( oldNote , newNote )
413
412
414
413
expect ( newNote . content ) . toBe ( expectedOutput )
415
414
} )
416
415
417
416
it ( 'should test that cloneAttachments finds all attachments and copies them to the new location' , function ( ) {
418
- const storageKey = 'storageKey'
419
- const storagePath = 'storagePath'
420
- const dummyStorage = { path : storagePath }
421
- const oldNote = { key : 'oldNoteKey' , content : 'oldNoteContent' }
422
- const newNote = { key : 'newNoteKey' , content : 'oldNoteContent' }
417
+ const storagePathOld = 'storagePathOld'
418
+ const storagePathNew = 'storagePathNew'
419
+ const dummyStorageOld = { path : storagePathOld }
420
+ const dummyStorageNew = { path : storagePathNew }
421
+ const oldNote = { key : 'oldNoteKey' , content : 'oldNoteContent' , storage : 'storageKeyOldNote' }
422
+ const newNote = { key : 'newNoteKey' , content : 'oldNoteContent' , storage : 'storageKeyNewNote' }
423
423
const testInput =
424
424
'Test input' +
425
425
' \n' +
@@ -430,17 +430,20 @@ it('should test that cloneAttachments finds all attachments and copies them to t
430
430
const copyFileSyncResp = { to : jest . fn ( ) }
431
431
sander . copyFileSync = jest . fn ( )
432
432
sander . copyFileSync . mockReturnValue ( copyFileSyncResp )
433
- findStorage . findStorage = jest . fn ( ( ) => dummyStorage )
433
+ findStorage . findStorage = jest . fn ( )
434
+ findStorage . findStorage . mockReturnValueOnce ( dummyStorageOld )
435
+ findStorage . findStorage . mockReturnValue ( dummyStorageNew )
434
436
435
- const pathAttachmentOneFrom = path . join ( storagePath , systemUnderTest . DESTINATION_FOLDER , oldNote . key , 'image.jpg' )
436
- const pathAttachmentOneTo = path . join ( storagePath , systemUnderTest . DESTINATION_FOLDER , newNote . key , 'image.jpg' )
437
+ const pathAttachmentOneFrom = path . join ( storagePathOld , systemUnderTest . DESTINATION_FOLDER , oldNote . key , 'image.jpg' )
438
+ const pathAttachmentOneTo = path . join ( storagePathNew , systemUnderTest . DESTINATION_FOLDER , newNote . key , 'image.jpg' )
437
439
438
- const pathAttachmentTwoFrom = path . join ( storagePath , systemUnderTest . DESTINATION_FOLDER , oldNote . key , 'pdf.pdf' )
439
- const pathAttachmentTwoTo = path . join ( storagePath , systemUnderTest . DESTINATION_FOLDER , newNote . key , 'pdf.pdf' )
440
+ const pathAttachmentTwoFrom = path . join ( storagePathOld , systemUnderTest . DESTINATION_FOLDER , oldNote . key , 'pdf.pdf' )
441
+ const pathAttachmentTwoTo = path . join ( storagePathNew , systemUnderTest . DESTINATION_FOLDER , newNote . key , 'pdf.pdf' )
440
442
441
- systemUnderTest . cloneAttachments ( storageKey , oldNote , newNote )
443
+ systemUnderTest . cloneAttachments ( oldNote , newNote )
442
444
443
- expect ( findStorage . findStorage ) . toHaveBeenCalledWith ( storageKey )
445
+ expect ( findStorage . findStorage ) . toHaveBeenCalledWith ( oldNote . storage )
446
+ expect ( findStorage . findStorage ) . toHaveBeenCalledWith ( newNote . storage )
444
447
expect ( sander . copyFileSync ) . toHaveBeenCalledTimes ( 2 )
445
448
expect ( copyFileSyncResp . to ) . toHaveBeenCalledTimes ( 2 )
446
449
expect ( sander . copyFileSync . mock . calls [ 0 ] [ 0 ] ) . toBe ( pathAttachmentOneFrom )
0 commit comments