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

Fixes #1822 -> fix for the broken tests

This commit is contained in:
ehhc
2018-04-21 16:32:27 +02:00
parent a76aed2d4e
commit 16794b9d78

View File

@@ -48,11 +48,13 @@ it('should test that copyAttachment works correctly assuming correct working of
const noteKey = 'noteKey' const noteKey = 'noteKey'
const dummyUniquePath = 'dummyPath' const dummyUniquePath = 'dummyPath'
const dummyStorage = {path: 'dummyStoragePath'} const dummyStorage = {path: 'dummyStoragePath'}
const dummyReadStream = {}
dummyReadStream.pipe = jest.fn()
dummyReadStream.on = jest.fn((event, callback) => { callback() })
fs.existsSync = jest.fn() fs.existsSync = jest.fn()
fs.existsSync.mockReturnValue(true) fs.existsSync.mockReturnValue(true)
fs.createReadStream = jest.fn() fs.createReadStream = jest.fn(() => dummyReadStream)
fs.createReadStream.mockReturnValue({pipe: jest.fn()})
fs.createWriteStream = jest.fn() fs.createWriteStream = jest.fn()
findStorage.findStorage = jest.fn() findStorage.findStorage = jest.fn()
@@ -75,7 +77,11 @@ it('should test that copyAttachment creates a new folder if the attachment folde
const noteKey = 'noteKey' const noteKey = 'noteKey'
const attachmentFolderPath = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER) const attachmentFolderPath = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER)
const attachmentFolderNoteKyPath = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER, noteKey) const attachmentFolderNoteKyPath = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER, noteKey)
const dummyReadStream = {}
dummyReadStream.pipe = jest.fn()
dummyReadStream.on = jest.fn()
fs.createReadStream = jest.fn(() => dummyReadStream)
fs.existsSync = jest.fn() fs.existsSync = jest.fn()
fs.existsSync.mockReturnValueOnce(true) fs.existsSync.mockReturnValueOnce(true)
fs.existsSync.mockReturnValueOnce(false) fs.existsSync.mockReturnValueOnce(false)
@@ -97,7 +103,11 @@ it('should test that copyAttachment creates a new folder if the attachment folde
it('should test that copyAttachment don\'t uses a random file name if not intended ', function () { it('should test that copyAttachment don\'t uses a random file name if not intended ', function () {
const dummyStorage = {path: 'dummyStoragePath'} const dummyStorage = {path: 'dummyStoragePath'}
const dummyReadStream = {}
dummyReadStream.pipe = jest.fn()
dummyReadStream.on = jest.fn()
fs.createReadStream = jest.fn(() => dummyReadStream)
fs.existsSync = jest.fn() fs.existsSync = jest.fn()
fs.existsSync.mockReturnValueOnce(true) fs.existsSync.mockReturnValueOnce(true)
fs.existsSync.mockReturnValueOnce(false) fs.existsSync.mockReturnValueOnce(false)