mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fix type
stoargeKey -> storageKey
This commit is contained in:
@@ -24,7 +24,7 @@ test.beforeEach((t) => {
|
|||||||
localStorage.setItem('storages', JSON.stringify([]))
|
localStorage.setItem('storages', JSON.stringify([]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('add a initialized storage', (t) => {
|
test.serial('Add Storage', (t) => {
|
||||||
const input = {
|
const input = {
|
||||||
type: 'FILESYSTEM',
|
type: 'FILESYSTEM',
|
||||||
name: 'add-storage1',
|
name: 'add-storage1',
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ test.beforeEach((t) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a folder', (t) => {
|
test.serial('Create a folder', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
const input = {
|
const input = {
|
||||||
name: 'created',
|
name: 'created',
|
||||||
color: '#ff5555'
|
color: '#ff5555'
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return createFolder(stoargeKey, input)
|
return createFolder(storageKey, input)
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
t.true(_.find(data.storage.folders, input) != null)
|
t.true(_.find(data.storage.folders, input) != null)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ global.navigator = window.navigator
|
|||||||
const Storage = require('dom-storage')
|
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 path = require('path')
|
||||||
const _ = require('lodash')
|
|
||||||
const TestDummy = require('../fixtures/TestDummy')
|
const TestDummy = require('../fixtures/TestDummy')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
@@ -23,7 +22,7 @@ test.beforeEach((t) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a note', (t) => {
|
test.serial('Create a note', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = t.context.storage.json.folders[0].key
|
||||||
|
|
||||||
const input1 = {
|
const input1 = {
|
||||||
@@ -50,14 +49,15 @@ test.serial('Create a note', (t) => {
|
|||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
createNote(stoargeKey, input1),
|
createNote(storageKey, input1),
|
||||||
createNote(stoargeKey, input2)
|
createNote(storageKey, input2)
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
let data1 = data[0]
|
let data1 = data[0]
|
||||||
let data2 = data[1]
|
let data2 = data[1]
|
||||||
|
|
||||||
|
t.is(storageKey, data1.storage)
|
||||||
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||||
t.is(input1.title, data1.title)
|
t.is(input1.title, data1.title)
|
||||||
t.is(input1.title, jsonData1.title)
|
t.is(input1.title, jsonData1.title)
|
||||||
@@ -72,6 +72,7 @@ test.serial('Create a note', (t) => {
|
|||||||
t.is(input1.snippets[0].name, data1.snippets[0].name)
|
t.is(input1.snippets[0].name, data1.snippets[0].name)
|
||||||
t.is(input1.snippets[0].name, jsonData1.snippets[0].name)
|
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'))
|
let jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
|
||||||
t.is(input2.title, data2.title)
|
t.is(input2.title, data2.title)
|
||||||
t.is(input2.title, jsonData2.title)
|
t.is(input2.title, jsonData2.title)
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ test.beforeEach((t) => {
|
|||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a folder', (t) => {
|
test.serial('Delete a folder', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = t.context.storage.json.folders[0].key
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return deleteFolder(stoargeKey, folderKey)
|
return deleteFolder(storageKey, folderKey)
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
t.true(_.find(data.storage.folders, {key: folderKey}) == null)
|
t.true(_.find(data.storage.folders, {key: folderKey}) == null)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ 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('Fetch storages and notes', (t) => {
|
test.serial('Initialize All Storages', (t) => {
|
||||||
const { v1StorageData, legacyStorageData, emptyStorageData } = t.context
|
const { v1StorageData, legacyStorageData, emptyStorageData } = t.context
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function test () {
|
.then(function test () {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ test.beforeEach((t) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Remove a storage', (t) => {
|
test('Remove a storage', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return removeStorage(stoargeKey)
|
return removeStorage(storageKey)
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
t.is(JSON.parse(localStorage.getItem('storages')).length, 0)
|
t.is(JSON.parse(localStorage.getItem('storages')).length, 0)
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ test.beforeEach((t) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Rename a storage', (t) => {
|
test.serial('Rename a storage', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return renameStorage(stoargeKey, 'changed')
|
return renameStorage(storageKey, 'changed')
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
||||||
t.true(_.find(cachedStorageList, {key: stoargeKey}).name === 'changed')
|
t.true(_.find(cachedStorageList, {key: storageKey}).name === 'changed')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ test.beforeEach((t) => {
|
|||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Create a folder', (t) => {
|
test.serial('Update a folder', (t) => {
|
||||||
const stoargeKey = t.context.storage.cache.key
|
const storageKey = t.context.storage.cache.key
|
||||||
const folderKey = t.context.storage.json.folders[0].key
|
const folderKey = t.context.storage.json.folders[0].key
|
||||||
const input = {
|
const input = {
|
||||||
name: 'changed',
|
name: 'changed',
|
||||||
@@ -30,7 +30,7 @@ test.serial('Create a folder', (t) => {
|
|||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function doTest () {
|
.then(function doTest () {
|
||||||
return updateFolder(stoargeKey, folderKey, input)
|
return updateFolder(storageKey, folderKey, input)
|
||||||
})
|
})
|
||||||
.then(function assert (data) {
|
.then(function assert (data) {
|
||||||
t.true(_.find(data.storage.folders, input) != null)
|
t.true(_.find(data.storage.folders, input) != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user