mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Merge pull request #1963 from ehhc/OnBlur_Throws_Exceptions_On_Snippet_Notes
OnBlur throws exceptions if the notetype is snippet -> Fixes #1962
This commit is contained in:
@@ -339,6 +339,38 @@ it('should test that deleteAttachmentsNotPresentInNote does not delete reference
|
||||
expect(fsUnlinkCallArguments.includes(path.join(attachmentFolderPath, dummyFilesInFolder[0]))).toBe(false)
|
||||
})
|
||||
|
||||
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()
|
||||
})
|
||||
|
||||
it('should test that moveAttachments moves attachments only if the source folder existed', function () {
|
||||
fse.existsSync = jest.fn(() => false)
|
||||
fse.moveSync = jest.fn()
|
||||
@@ -403,6 +435,8 @@ it('should test that cloneAttachments modifies the content of the new note corre
|
||||
' \n' +
|
||||
'[' + systemUnderTest.STORAGE_FOLDER_PLACEHOLDER + path.sep + oldNote.key + path.sep + 'pdf.pdf](pdf})'
|
||||
newNote.content = testInput
|
||||
findStorage.findStorage = jest.fn()
|
||||
findStorage.findStorage.mockReturnValue({path: 'dummyStoragePath'})
|
||||
|
||||
const expectedOutput =
|
||||
'Test input' +
|
||||
|
||||
Reference in New Issue
Block a user