mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-23 06:31:51 +00:00
fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)
This commit is contained in:
@@ -10,7 +10,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 _ = require('lodash')
|
||||
const TestDummy = require('../fixtures/TestDummy')
|
||||
@@ -20,12 +23,12 @@ const CSON = require('@rokt33r/season')
|
||||
|
||||
const storagePath = path.join(os.tmpdir(), 'test/delete-folder')
|
||||
|
||||
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 folder', (t) => {
|
||||
test.serial('Delete a folder', t => {
|
||||
const storageKey = t.context.storage.cache.key
|
||||
const folderKey = t.context.storage.json.folders[0].key
|
||||
let noteKey
|
||||
@@ -33,44 +36,64 @@ test.serial('Delete a folder', (t) => {
|
||||
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 prepare () {
|
||||
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 prepare() {
|
||||
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
|
||||
)
|
||||
)
|
||||
noteKey = data.key
|
||||
|
||||
return data
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
.then(function doTest () {
|
||||
.then(function doTest() {
|
||||
return deleteFolder(storageKey, folderKey)
|
||||
})
|
||||
.then(function assert (data) {
|
||||
t.true(_.find(data.storage.folders, {key: folderKey}) == null)
|
||||
const jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
.then(function assert(data) {
|
||||
t.true(_.find(data.storage.folders, { key: folderKey }) == null)
|
||||
const jsonData = CSON.readFileSync(
|
||||
path.join(data.storage.path, 'boostnote.json')
|
||||
)
|
||||
|
||||
t.true(_.find(jsonData.folders, {key: folderKey}) == null)
|
||||
t.true(_.find(jsonData.folders, { key: folderKey }) == null)
|
||||
const notePaths = sander.readdirSync(data.storage.path, 'notes')
|
||||
t.is(notePaths.length, t.context.storage.notes.filter((note) => note.folder !== folderKey).length)
|
||||
t.is(
|
||||
notePaths.length,
|
||||
t.context.storage.notes.filter(note => note.folder !== folderKey).length
|
||||
)
|
||||
|
||||
const attachmentFolderPath = path.join(storagePath, attachmentManagement.DESTINATION_FOLDER, noteKey)
|
||||
const attachmentFolderPath = path.join(
|
||||
storagePath,
|
||||
attachmentManagement.DESTINATION_FOLDER,
|
||||
noteKey
|
||||
)
|
||||
t.false(fs.existsSync(attachmentFolderPath))
|
||||
})
|
||||
})
|
||||
|
||||
test.after.always(function after () {
|
||||
test.after.always(function after() {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user