1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Deleting a note should also delete the attachments -> fixes #1900

This commit is contained in:
ehhc
2018-05-10 21:36:58 +02:00
parent 90e8dd038d
commit 73ba8b8b13
4 changed files with 42 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ const sander = require('sander')
const os = require('os')
const CSON = require('@rokt33r/season')
const faker = require('faker')
const fs = require('fs')
const attachmentManagement = require('browser/main/lib/dataApi/attachmentManagement')
const storagePath = path.join(os.tmpdir(), 'test/delete-note')
@@ -42,6 +44,10 @@ test.serial('Delete a note', (t) => {
return Promise.resolve()
.then(function doTest () {
return createNote(storageKey, input1)
.then(function createAttachmentFolder (data) {
fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.noteKey))
return data
})
.then(function (data) {
return deleteNote(storageKey, data.key)
})
@@ -54,6 +60,10 @@ test.serial('Delete a note', (t) => {
t.is(err.code, 'ENOENT')
}
})
.then(function assertAttachmentFolderDeleted (data) {
const attachmentFolderPath = path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.noteKey)
t.assert(fs.existsSync(attachmentFolderPath) === false, 'Attachment folder was not deleted')
})
})
test.after(function after () {