mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
cleanup test
remove crypto dependency from renameStorage refactor removeStorage remove dummy files
This commit is contained in:
@@ -8,23 +8,22 @@ 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 crypto = require('crypto')
|
const TestDummy = require('../fixtures/TestDummy')
|
||||||
|
const sander = require('sander')
|
||||||
|
const os = require('os')
|
||||||
|
|
||||||
|
const storagePath = path.join(os.tmpdir(), 'test/remove-storage')
|
||||||
|
|
||||||
|
test.beforeEach((t) => {
|
||||||
|
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||||
|
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||||
|
})
|
||||||
|
|
||||||
test('Remove a storage', (t) => {
|
test('Remove a storage', (t) => {
|
||||||
const dummyStoragePath = path.join(__dirname, '..', 'dummy/dummyStorage')
|
const stoargeKey = t.context.storage.cache.key
|
||||||
const dummyStorageKey = crypto.randomBytes(6).toString('hex')
|
|
||||||
const dummyRawStorage = {
|
|
||||||
name: 'test1',
|
|
||||||
key: dummyStorageKey,
|
|
||||||
path: dummyStoragePath
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function before () {
|
.then(function doTest () {
|
||||||
localStorage.setItem('storages', JSON.stringify([dummyRawStorage]))
|
return removeStorage(stoargeKey)
|
||||||
})
|
|
||||||
.then(function test () {
|
|
||||||
return removeStorage(dummyStorageKey)
|
|
||||||
})
|
})
|
||||||
.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)
|
||||||
@@ -33,4 +32,5 @@ test('Remove a storage', (t) => {
|
|||||||
|
|
||||||
test.after(function after () {
|
test.after(function after () {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
|
sander.rimrafSync(storagePath)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ 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 crypto = require('crypto')
|
|
||||||
const _ = require('lodash')
|
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')
|
||||||
|
|
||||||
const storagePath = path.join(os.tmpdir(), 'test/rename-storage')
|
const storagePath = path.join(os.tmpdir(), 'test/rename-storage')
|
||||||
|
|
||||||
test.beforeEach((t) => {
|
test.beforeEach((t) => {
|
||||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"folders": [
|
|
||||||
{
|
|
||||||
"key": "fc6ba88e8ecf",
|
|
||||||
"name": "test",
|
|
||||||
"color": "#FF5555"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"notes": [
|
|
||||||
{
|
|
||||||
"tags": [],
|
|
||||||
"title": "Footnote test",
|
|
||||||
"content": "# Footnote test\n\ntest test",
|
|
||||||
"type": "MARKDOWN_NOTE",
|
|
||||||
"key": "93c6ac2a7953",
|
|
||||||
"isStarred": false,
|
|
||||||
"createdAt": "2016-07-25T16:19:55.620Z",
|
|
||||||
"updatedAt": "2016-07-26T08:00:11.326Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tags": [],
|
|
||||||
"title": "Checkbox test",
|
|
||||||
"content": "# Checkbox test\n\n- [x] Task1\n- [ ] Task2\n- [ ] Task3\n\n",
|
|
||||||
"type": "MARKDOWN_NOTE",
|
|
||||||
"key": "4568d84331d9",
|
|
||||||
"isStarred": false,
|
|
||||||
"createdAt": "2016-07-25T16:58:43.685Z",
|
|
||||||
"updatedAt": "2016-08-21T06:14:50.381Z"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user