mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
fixed eslint warnings
This commit is contained in:
@@ -36,7 +36,7 @@ test.serial('Add Storage', (t) => {
|
||||
return addStorage(input)
|
||||
})
|
||||
.then(function validateResult (data) {
|
||||
let { storage, notes } = data
|
||||
const { storage, notes } = data
|
||||
|
||||
// Check data.storage
|
||||
t.true(_.isString(storage.key))
|
||||
@@ -53,13 +53,13 @@ test.serial('Add Storage', (t) => {
|
||||
})
|
||||
|
||||
// Check localStorage
|
||||
let cacheData = _.find(JSON.parse(localStorage.getItem('storages')), {key: data.storage.key})
|
||||
const cacheData = _.find(JSON.parse(localStorage.getItem('storages')), {key: data.storage.key})
|
||||
t.is(cacheData.name, input.name)
|
||||
t.is(cacheData.type, input.type)
|
||||
t.is(cacheData.path, input.path)
|
||||
|
||||
// Check boostnote.json
|
||||
let jsonData = CSON.readFileSync(path.join(storage.path, 'boostnote.json'))
|
||||
const jsonData = CSON.readFileSync(path.join(storage.path, 'boostnote.json'))
|
||||
t.true(_.isArray(jsonData.folders))
|
||||
t.is(jsonData.version, '1.0')
|
||||
t.is(jsonData.folders.length, t.context.v1StorageData.json.folders.length)
|
||||
|
||||
@@ -33,7 +33,7 @@ test.serial('Create a folder', (t) => {
|
||||
})
|
||||
.then(function assert (data) {
|
||||
t.true(_.find(data.storage.folders, input) != null)
|
||||
let jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
const jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
console.log(path.join(data.storage.path, 'boostnote.json'))
|
||||
t.true(_.find(jsonData.folders, input) != null)
|
||||
})
|
||||
|
||||
@@ -54,11 +54,11 @@ test.serial('Create a note', (t) => {
|
||||
])
|
||||
})
|
||||
.then(function assert (data) {
|
||||
let data1 = data[0]
|
||||
let data2 = data[1]
|
||||
const data1 = data[0]
|
||||
const data2 = data[1]
|
||||
|
||||
t.is(storageKey, data1.storage)
|
||||
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||
const jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||
t.is(input1.title, data1.title)
|
||||
t.is(input1.title, jsonData1.title)
|
||||
t.is(input1.description, data1.description)
|
||||
@@ -73,7 +73,7 @@ test.serial('Create a note', (t) => {
|
||||
t.is(input1.snippets[0].name, jsonData1.snippets[0].name)
|
||||
|
||||
t.is(storageKey, data2.storage)
|
||||
let jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
|
||||
const jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
|
||||
t.is(input2.title, data2.title)
|
||||
t.is(input2.title, jsonData2.title)
|
||||
t.is(input2.content, data2.content)
|
||||
|
||||
@@ -31,10 +31,10 @@ test.serial('Delete a folder', (t) => {
|
||||
})
|
||||
.then(function assert (data) {
|
||||
t.true(_.find(data.storage.folders, {key: folderKey}) == null)
|
||||
let jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
const jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
|
||||
t.true(_.find(jsonData.folders, {key: folderKey}) == null)
|
||||
let notePaths = sander.readdirSync(data.storage.path, 'notes')
|
||||
const notePaths = sander.readdirSync(data.storage.path, 'notes')
|
||||
t.is(notePaths.length, t.context.storage.notes.filter((note) => note.folder !== folderKey).length)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ const os = require('os')
|
||||
const dummyStoragePath = path.join(os.tmpdir(), 'test/migrate-test-storage')
|
||||
|
||||
test.beforeEach((t) => {
|
||||
let dummyData = t.context.dummyData = TestDummy.dummyLegacyStorage(dummyStoragePath)
|
||||
const dummyData = t.context.dummyData = TestDummy.dummyLegacyStorage(dummyStoragePath)
|
||||
console.log('init count', dummyData.notes.length)
|
||||
localStorage.setItem('storages', JSON.stringify([dummyData.cache]))
|
||||
})
|
||||
@@ -32,11 +32,11 @@ test.serial('Migrate legacy storage into v1 storage', (t) => {
|
||||
t.true(data)
|
||||
|
||||
// Check all notes migrated.
|
||||
let dummyData = t.context.dummyData
|
||||
let noteDirPath = path.join(dummyStoragePath, 'notes')
|
||||
let fileList = sander.readdirSync(noteDirPath)
|
||||
const dummyData = t.context.dummyData
|
||||
const noteDirPath = path.join(dummyStoragePath, 'notes')
|
||||
const fileList = sander.readdirSync(noteDirPath)
|
||||
t.is(dummyData.notes.length, fileList.length)
|
||||
let noteMap = fileList
|
||||
const noteMap = fileList
|
||||
.map((filePath) => {
|
||||
return CSON.readFileSync(path.join(noteDirPath, filePath))
|
||||
})
|
||||
|
||||
@@ -38,15 +38,15 @@ test.serial('Move a note', (t) => {
|
||||
])
|
||||
})
|
||||
.then(function assert (data) {
|
||||
let data1 = data[0]
|
||||
let data2 = data[1]
|
||||
const data1 = data[0]
|
||||
const data2 = data[1]
|
||||
|
||||
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||
const 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.key + '.cson'))
|
||||
const jsonData2 = CSON.readFileSync(path.join(storagePath2, 'notes', data2.key + '.cson'))
|
||||
t.is(jsonData2.folder, folderKey2)
|
||||
t.is(jsonData2.title, note2.title)
|
||||
try {
|
||||
|
||||
@@ -27,7 +27,7 @@ test.serial('Rename a storage', (t) => {
|
||||
return renameStorage(storageKey, 'changed')
|
||||
})
|
||||
.then(function assert (data) {
|
||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
||||
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
||||
t.true(_.find(cachedStorageList, {key: storageKey}).name === 'changed')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -34,8 +34,7 @@ test.serial('Reorder a folder', (t) => {
|
||||
t.true(_.nth(data.storage.folders, 0).key === secondFolderKey)
|
||||
t.true(_.nth(data.storage.folders, 1).key === firstFolderKey)
|
||||
|
||||
let jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
console.log(path.join(data.storage.path, 'boostnote.json'))
|
||||
const jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
|
||||
t.true(_.nth(jsonData.folders, 0).key === secondFolderKey)
|
||||
t.true(_.nth(jsonData.folders, 1).key === firstFolderKey)
|
||||
|
||||
@@ -34,7 +34,7 @@ test.serial('Update a folder', (t) => {
|
||||
})
|
||||
.then(function assert (data) {
|
||||
t.true(_.find(data.storage.folders, input) != null)
|
||||
let jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
const jsonData = CSON.readFileSync(path.join(data.storage.path, 'boostnote.json'))
|
||||
console.log(path.join(data.storage.path, 'boostnote.json'))
|
||||
t.true(_.find(jsonData.folders, input) != null)
|
||||
})
|
||||
|
||||
@@ -74,8 +74,8 @@ test.serial('Update a note', (t) => {
|
||||
createNote(storageKey, input2)
|
||||
])
|
||||
.then(function updateNotes (data) {
|
||||
let data1 = data[0]
|
||||
let data2 = data[1]
|
||||
const data1 = data[0]
|
||||
const data2 = data[1]
|
||||
return Promise.all([
|
||||
updateNote(data1.storage, data1.key, input3),
|
||||
updateNote(data1.storage, data2.key, input4)
|
||||
@@ -83,10 +83,10 @@ test.serial('Update a note', (t) => {
|
||||
})
|
||||
})
|
||||
.then(function assert (data) {
|
||||
let data1 = data[0]
|
||||
let data2 = data[1]
|
||||
const data1 = data[0]
|
||||
const data2 = data[1]
|
||||
|
||||
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||
const jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||
t.is(input3.title, data1.title)
|
||||
t.is(input3.title, jsonData1.title)
|
||||
t.is(input3.description, data1.description)
|
||||
@@ -100,7 +100,7 @@ test.serial('Update a note', (t) => {
|
||||
t.is(input3.snippets[0].name, data1.snippets[0].name)
|
||||
t.is(input3.snippets[0].name, jsonData1.snippets[0].name)
|
||||
|
||||
let jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
|
||||
const jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
|
||||
t.is(input4.title, data2.title)
|
||||
t.is(input4.title, jsonData2.title)
|
||||
t.is(input4.content, data2.content)
|
||||
|
||||
Reference in New Issue
Block a user