mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-22 06:01:45 +00:00
Deleting a note should also delete the attachments -> fixes #1900
This commit is contained in:
@@ -7,6 +7,7 @@ const findStorage = require('browser/lib/findStorage')
|
||||
jest.mock('unique-slug')
|
||||
const uniqueSlug = require('unique-slug')
|
||||
const mdurl = require('mdurl')
|
||||
const sander = require('sander')
|
||||
|
||||
const systemUnderTest = require('browser/main/lib/dataApi/attachmentManagement')
|
||||
|
||||
@@ -260,3 +261,16 @@ it('should remove the all ":storage" and noteKey references', function () {
|
||||
const actual = systemUnderTest.removeStorageAndNoteReferences(testInput, noteKey)
|
||||
expect(actual).toEqual(expectedOutput)
|
||||
})
|
||||
|
||||
it('should delete the correct attachment folder if a note is deleted', function () {
|
||||
const dummyStorage = {path: 'dummyStoragePath'}
|
||||
const storageKey = 'storageKey'
|
||||
const noteKey = 'noteKey'
|
||||
findStorage.findStorage = jest.fn(() => dummyStorage)
|
||||
sander.rimraf = jest.fn()
|
||||
|
||||
const expectedPathToBeDeleted = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER, noteKey)
|
||||
systemUnderTest.deleteAttachmentFolder(storageKey, noteKey)
|
||||
expect(findStorage.findStorage).toHaveBeenCalledWith(storageKey)
|
||||
expect(sander.rimraf).toHaveBeenCalledWith(expectedPathToBeDeleted)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user