1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

fix moveNote Api

This commit is contained in:
Dick Choi
2016-08-30 02:33:00 +09:00
parent 33a11ac2e5
commit ba374e08ff
2 changed files with 5 additions and 7 deletions

View File

@@ -65,15 +65,13 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
noteData.folder = newFolderKey
noteData.key = newNoteKey
noteData.storage = newStorageKey
noteData.updatedAt = new Date()
return noteData
})
.then(function writeAndReturn (noteData) {
CSON.writeFileSync(path.join(newStorage.path, 'notes', noteData.key + '.cson'), _.omit(noteData, ['key', 'storage']))
return {
oldStorageKey: storageKey,
oldNoteKey: noteKey,
note: noteData
}
return noteData
})
.then(function deleteOldNote (data) {
if (storageKey !== newStorageKey) {

View File

@@ -42,12 +42,12 @@ test.serial('Move a note', (t) => {
let data1 = data[0]
let data2 = data[1]
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.note.key + '.cson'))
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
t.is(jsonData1.folder, folderKey1)
t.is(jsonData1.title, note1.title)
let jsonData2 = CSON.readFileSync(path.join(storagePath2, 'notes', data2.note.key + '.cson'))
let jsonData2 = CSON.readFileSync(path.join(storagePath2, 'notes', data2.key + '.cson'))
t.is(jsonData2.folder, folderKey2)
t.is(jsonData2.title, note2.title)
try {