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

Merge branch 'master' into Moving_Note_With_Attachment

This commit is contained in:
Junyoung Choi (Sai)
2018-05-17 01:28:47 +09:00
committed by GitHub
15 changed files with 95 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ jest.mock('unique-slug')
const uniqueSlug = require('unique-slug')
const mdurl = require('mdurl')
const fse = require('fs-extra')
const sander = require('sander')
const systemUnderTest = require('browser/main/lib/dataApi/attachmentManagement')
@@ -262,6 +263,19 @@ it('should remove the all ":storage" and noteKey references', function () {
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.rimrafSync = jest.fn()
const expectedPathToBeDeleted = path.join(dummyStorage.path, systemUnderTest.DESTINATION_FOLDER, noteKey)
systemUnderTest.deleteAttachmentFolder(storageKey, noteKey)
expect(findStorage.findStorage).toHaveBeenCalledWith(storageKey)
expect(sander.rimrafSync).toHaveBeenCalledWith(expectedPathToBeDeleted)
})
it('should test that deleteAttachmentsNotPresentInNote deletes all unreferenced attachments ', function () {
const dummyStorage = {path: 'dummyStoragePath'}
const noteKey = 'noteKey'