1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 18:56:22 +00:00

fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)

This commit is contained in:
Nguyen Viet Hung
2020-02-05 13:28:27 +13:00
committed by GitHub
parent 051ce9e208
commit 592aca1539
186 changed files with 9233 additions and 5565 deletions

View File

@@ -6,7 +6,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')
@@ -18,24 +21,24 @@ const v1StoragePath = path.join(os.tmpdir(), 'test/addStorage-v1-storage')
// const legacyStoragePath = path.join(os.tmpdir(), 'test/addStorage-legacy-storage')
// const emptyDirPath = path.join(os.tmpdir(), 'test/addStorage-empty-storage')
test.beforeEach((t) => {
test.beforeEach(t => {
t.context.v1StorageData = TestDummy.dummyStorage(v1StoragePath)
// t.context.legacyStorageData = TestDummy.dummyLegacyStorage(legacyStoragePath)
localStorage.setItem('storages', JSON.stringify([]))
})
test.serial('Add Storage', (t) => {
test.serial('Add Storage', t => {
const input = {
type: 'FILESYSTEM',
name: 'add-storage1',
path: v1StoragePath
}
return Promise.resolve()
.then(function doTest () {
.then(function doTest() {
return addStorage(input)
})
.then(function validateResult (data) {
.then(function validateResult(data) {
const { storage, notes } = data
// Check data.storage
@@ -48,18 +51,22 @@ test.serial('Add Storage', (t) => {
// Check data.notes
t.is(notes.length, t.context.v1StorageData.notes.length)
notes.forEach(function validateNote (note) {
notes.forEach(function validateNote(note) {
t.is(note.storage, storage.key)
})
// Check localStorage
const 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
const 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)