@@ -48,11 +48,13 @@ it('should test that copyAttachment works correctly assuming correct working of
48
48
const noteKey = 'noteKey'
49
49
const dummyUniquePath = 'dummyPath'
50
50
const dummyStorage = { path : 'dummyStoragePath' }
51
+ const dummyReadStream = { }
51
52
53
+ dummyReadStream . pipe = jest . fn ( )
54
+ dummyReadStream . on = jest . fn ( ( event , callback ) => { callback ( ) } )
52
55
fs . existsSync = jest . fn ( )
53
56
fs . existsSync . mockReturnValue ( true )
54
- fs . createReadStream = jest . fn ( )
55
- fs . createReadStream . mockReturnValue ( { pipe : jest . fn ( ) } )
57
+ fs . createReadStream = jest . fn ( ( ) => dummyReadStream )
56
58
fs . createWriteStream = jest . fn ( )
57
59
58
60
findStorage . findStorage = jest . fn ( )
@@ -75,7 +77,11 @@ it('should test that copyAttachment creates a new folder if the attachment folde
75
77
const noteKey = 'noteKey'
76
78
const attachmentFolderPath = path . join ( dummyStorage . path , systemUnderTest . DESTINATION_FOLDER )
77
79
const attachmentFolderNoteKyPath = path . join ( dummyStorage . path , systemUnderTest . DESTINATION_FOLDER , noteKey )
80
+ const dummyReadStream = { }
78
81
82
+ dummyReadStream . pipe = jest . fn ( )
83
+ dummyReadStream . on = jest . fn ( )
84
+ fs . createReadStream = jest . fn ( ( ) => dummyReadStream )
79
85
fs . existsSync = jest . fn ( )
80
86
fs . existsSync . mockReturnValueOnce ( true )
81
87
fs . existsSync . mockReturnValueOnce ( false )
@@ -97,7 +103,11 @@ it('should test that copyAttachment creates a new folder if the attachment folde
97
103
98
104
it ( 'should test that copyAttachment don\'t uses a random file name if not intended ' , function ( ) {
99
105
const dummyStorage = { path : 'dummyStoragePath' }
106
+ const dummyReadStream = { }
100
107
108
+ dummyReadStream . pipe = jest . fn ( )
109
+ dummyReadStream . on = jest . fn ( )
110
+ fs . createReadStream = jest . fn ( ( ) => dummyReadStream )
101
111
fs . existsSync = jest . fn ( )
102
112
fs . existsSync . mockReturnValueOnce ( true )
103
113
fs . existsSync . mockReturnValueOnce ( false )
0 commit comments