1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-20 21:21:59 +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 keygen = require('browser/lib/keygen')
@@ -18,11 +21,16 @@ const v1StoragePath = path.join(os.tmpdir(), 'test/init-v1-storage')
const legacyStoragePath = path.join(os.tmpdir(), 'test/init-legacy-storage')
const emptyDirPath = path.join(os.tmpdir(), 'test/init-empty-storage')
test.beforeEach((t) => {
test.beforeEach(t => {
localStorage.clear()
// Prepare 3 types of dir
t.context.v1StorageData = TestDummy.dummyStorage(v1StoragePath, {cache: {name: 'v1'}})
t.context.legacyStorageData = TestDummy.dummyLegacyStorage(legacyStoragePath, {cache: {name: 'legacy'}})
t.context.v1StorageData = TestDummy.dummyStorage(v1StoragePath, {
cache: { name: 'v1' }
})
t.context.legacyStorageData = TestDummy.dummyLegacyStorage(
legacyStoragePath,
{ cache: { name: 'legacy' } }
)
t.context.emptyStorageData = {
cache: {
type: 'FILESYSTEM',
@@ -32,27 +40,37 @@ test.beforeEach((t) => {
}
}
localStorage.setItem('storages', JSON.stringify([t.context.v1StorageData.cache, t.context.legacyStorageData.cache, t.context.emptyStorageData.cache]))
localStorage.setItem(
'storages',
JSON.stringify([
t.context.v1StorageData.cache,
t.context.legacyStorageData.cache,
t.context.emptyStorageData.cache
])
)
})
test.serial('Initialize All Storages', (t) => {
test.serial('Initialize All Storages', t => {
const { v1StorageData, legacyStorageData } = t.context
return Promise.resolve()
.then(function test () {
.then(function test() {
return init()
})
.then(function assert (data) {
.then(function assert(data) {
t.true(Array.isArray(data.storages))
t.is(data.notes.length, v1StorageData.notes.length + legacyStorageData.notes.length)
t.is(
data.notes.length,
v1StorageData.notes.length + legacyStorageData.notes.length
)
t.is(data.storages.length, 3)
data.storages.forEach(function assertStorage (storage) {
data.storages.forEach(function assertStorage(storage) {
t.true(_.isString(storage.key))
t.true(_.isString(storage.name))
t.true(storage.type === 'FILESYSTEM')
t.true(_.isString(storage.path))
})
})
.then(function after () {
.then(function after() {
localStorage.clear()
})
})