From 03fd1e29e37a84dacaea3bce8cdad7cda55599a4 Mon Sep 17 00:00:00 2001 From: ehhc Date: Thu, 10 May 2018 22:30:13 +0200 Subject: [PATCH] Fix for the broken test --- browser/main/lib/dataApi/attachmentManagement.js | 2 +- tests/dataApi/deleteNote-test.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index ace33464..a1030aee 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -199,7 +199,7 @@ function removeStorageAndNoteReferences (input, noteKey) { function deleteAttachmentFolder (storageKey, noteKey) { const storagePath = findStorage.findStorage(storageKey) const noteAttachmentPath = path.join(storagePath.path, DESTINATION_FOLDER, noteKey) - sander.rimraf(noteAttachmentPath) + sander.rimrafSync(noteAttachmentPath) } module.exports = { diff --git a/tests/dataApi/deleteNote-test.js b/tests/dataApi/deleteNote-test.js index c9a33145..9c809dcf 100644 --- a/tests/dataApi/deleteNote-test.js +++ b/tests/dataApi/deleteNote-test.js @@ -45,7 +45,8 @@ test.serial('Delete a note', (t) => { .then(function doTest () { return createNote(storageKey, input1) .then(function createAttachmentFolder (data) { - fs.mkdirSync(path.join(storagePath.path, attachmentManagement.DESTINATION_FOLDER, data.noteKey)) + fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER)) + fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.key)) return data }) .then(function (data) { @@ -54,15 +55,16 @@ test.serial('Delete a note', (t) => { }) .then(function assert (data) { try { - CSON.readFileSync(path.join(storagePath.path, 'notes', data.noteKey + '.cson')) + CSON.readFileSync(path.join(storagePath, 'notes', data.noteKey + '.cson')) t.fail('note cson must be deleted.') } catch (err) { t.is(err.code, 'ENOENT') + return data } }) .then(function assertAttachmentFolderDeleted (data) { - const attachmentFolderPath = path.join(storagePath.path, attachmentManagement.DESTINATION_FOLDER, data.noteKey) - t.assert(fs.existsSync(attachmentFolderPath) === false, 'Attachment folder was not deleted') + const attachmentFolderPath = path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.noteKey) + t.is(fs.existsSync(attachmentFolderPath), false) }) })