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

Fix for the issues raised in the code review

This commit is contained in:
ehhc
2018-05-28 08:58:09 +02:00
parent 2f4eb595f6
commit 8132dd6847
2 changed files with 33 additions and 1 deletions

View File

@@ -383,3 +383,35 @@ it('should test that moveAttachments returns a correct modified content version'
const actualContent = systemUnderTest.moveAttachments(oldPath, newPath, oldNoteKey, newNoteKey, testInput)
expect(actualContent).toBe(expectedOutput)
})
it('should test that deleteAttachmentsNotPresentInNote does nothing if noteKey, storageKey or noteContent was null', function () {
const noteKey = null
const storageKey = null
const markdownContent = ''
findStorage.findStorage = jest.fn()
fs.existsSync = jest.fn()
fs.readdir = jest.fn()
fs.unlink = jest.fn()
systemUnderTest.deleteAttachmentsNotPresentInNote(markdownContent, storageKey, noteKey)
expect(fs.existsSync).not.toHaveBeenCalled()
expect(fs.readdir).not.toHaveBeenCalled()
expect(fs.unlink).not.toHaveBeenCalled()
})
it('should test that deleteAttachmentsNotPresentInNote does nothing if noteKey, storageKey or noteContent was undefined', function () {
const noteKey = undefined
const storageKey = undefined
const markdownContent = ''
findStorage.findStorage = jest.fn()
fs.existsSync = jest.fn()
fs.readdir = jest.fn()
fs.unlink = jest.fn()
systemUnderTest.deleteAttachmentsNotPresentInNote(markdownContent, storageKey, noteKey)
expect(fs.existsSync).not.toHaveBeenCalled()
expect(fs.readdir).not.toHaveBeenCalled()
expect(fs.unlink).not.toHaveBeenCalled()
})