mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-19 20:51:42 +00:00
fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)
This commit is contained in:
@@ -7,7 +7,10 @@ global.window = document.defaultView
|
||||
global.navigator = window.navigator
|
||||
|
||||
const Storage = require('dom-storage')
|
||||
const localStorage = window.localStorage = global.localStorage = new Storage(null, { strict: true })
|
||||
const localStorage = (window.localStorage = global.localStorage = new Storage(
|
||||
null,
|
||||
{ strict: true }
|
||||
))
|
||||
const path = require('path')
|
||||
const TestDummy = require('../fixtures/TestDummy')
|
||||
const sander = require('sander')
|
||||
@@ -19,56 +22,72 @@ const attachmentManagement = require('browser/main/lib/dataApi/attachmentManagem
|
||||
|
||||
const storagePath = path.join(os.tmpdir(), 'test/delete-note')
|
||||
|
||||
test.beforeEach((t) => {
|
||||
test.beforeEach(t => {
|
||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||
})
|
||||
|
||||
test.serial('Delete a note', (t) => {
|
||||
test.serial('Delete a note', t => {
|
||||
const storageKey = t.context.storage.cache.key
|
||||
const folderKey = t.context.storage.json.folders[0].key
|
||||
|
||||
const input1 = {
|
||||
type: 'SNIPPET_NOTE',
|
||||
description: faker.lorem.lines(),
|
||||
snippets: [{
|
||||
name: faker.system.fileName(),
|
||||
mode: 'text',
|
||||
content: faker.lorem.lines()
|
||||
}],
|
||||
snippets: [
|
||||
{
|
||||
name: faker.system.fileName(),
|
||||
mode: 'text',
|
||||
content: faker.lorem.lines()
|
||||
}
|
||||
],
|
||||
tags: faker.lorem.words().split(' '),
|
||||
folder: folderKey
|
||||
}
|
||||
input1.title = input1.description.split('\n').shift()
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function doTest () {
|
||||
.then(function doTest() {
|
||||
return createNote(storageKey, input1)
|
||||
.then(function createAttachmentFolder (data) {
|
||||
fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER))
|
||||
fs.mkdirSync(path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, data.key))
|
||||
.then(function createAttachmentFolder(data) {
|
||||
fs.mkdirSync(
|
||||
path.join(storagePath, attachmentManagement.DESTINATION_FOLDER)
|
||||
)
|
||||
fs.mkdirSync(
|
||||
path.join(
|
||||
storagePath,
|
||||
attachmentManagement.DESTINATION_FOLDER,
|
||||
data.key
|
||||
)
|
||||
)
|
||||
return data
|
||||
})
|
||||
.then(function (data) {
|
||||
.then(function(data) {
|
||||
return deleteNote(storageKey, data.key)
|
||||
})
|
||||
})
|
||||
.then(function assert (data) {
|
||||
.then(function assert(data) {
|
||||
try {
|
||||
CSON.readFileSync(path.join(storagePath, '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, attachmentManagement.DESTINATION_FOLDER, data.noteKey)
|
||||
.then(function assertAttachmentFolderDeleted(data) {
|
||||
const attachmentFolderPath = path.join(
|
||||
storagePath,
|
||||
attachmentManagement.DESTINATION_FOLDER,
|
||||
data.noteKey
|
||||
)
|
||||
t.is(fs.existsSync(attachmentFolderPath), false)
|
||||
})
|
||||
})
|
||||
|
||||
test.after(function after () {
|
||||
test.after(function after() {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user