mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 10:16:26 +00:00
update dummy data
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
"postinstall": "npm run vendor",
|
"postinstall": "npm run vendor",
|
||||||
"vendor": "oh-my-cdn",
|
"vendor": "oh-my-cdn",
|
||||||
"compile": "grunt compile",
|
"compile": "grunt compile",
|
||||||
"test": "ava"
|
"test": "NODE_ENV=test ava"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"electron-version": "1.2.8"
|
"electron-version": "1.2.8"
|
||||||
|
|||||||
@@ -7,33 +7,21 @@ 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 sander = require('sander')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
|
||||||
const dummyStoragePath = path.join(__dirname, '..', 'sandbox')
|
test.serial('Fetch storages and notes', (t) => {
|
||||||
const dummyRawStorage = {
|
const dummyStoragePath = path.join(__dirname, '..', 'dummy/dummyStorage')
|
||||||
name: 'test',
|
const dummyRawStorage = {
|
||||||
|
name: 'test1',
|
||||||
key: crypto.randomBytes(6).toString('hex'),
|
key: crypto.randomBytes(6).toString('hex'),
|
||||||
path: dummyStoragePath
|
path: dummyStoragePath
|
||||||
}
|
}
|
||||||
|
const dummyFolderKey = 'fc6ba88e8ecf'
|
||||||
test.serial('fetch storages and notes', (t) => {
|
|
||||||
const boostnoteJSONPath = path.join(dummyStoragePath, 'boostnote.json')
|
|
||||||
const dummyFolderKey = crypto.randomBytes(6).toString('hex')
|
|
||||||
const dummyFolders = [{
|
|
||||||
key: dummyFolderKey,
|
|
||||||
name: 'test1',
|
|
||||||
color: '#f55'
|
|
||||||
}]
|
|
||||||
const dummyFolderDataJSONPath = path.join(dummyStoragePath, dummyFolderKey, 'data.json')
|
|
||||||
const dummyNotesJSONString = sander.readFileSync(path.join(__dirname, '../dummy/data.json'))
|
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function before () {
|
.then(function before () {
|
||||||
localStorage.setItem('storages', JSON.stringify([dummyRawStorage]))
|
localStorage.setItem('storages', JSON.stringify([dummyRawStorage]))
|
||||||
sander.writeFileSync(boostnoteJSONPath, JSON.stringify({folders: dummyFolders}))
|
|
||||||
sander.writeFileSync(dummyFolderDataJSONPath, dummyNotesJSONString)
|
|
||||||
})
|
})
|
||||||
.then(function test () {
|
.then(function test () {
|
||||||
return init()
|
return init()
|
||||||
@@ -54,12 +42,16 @@ test.serial('fetch storages and notes', (t) => {
|
|||||||
})
|
})
|
||||||
.then(function after () {
|
.then(function after () {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
sander.unlinkSync(boostnoteJSONPath)
|
|
||||||
sander.unlinkSync(dummyFolderDataJSONPath)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Fetch storages. case: storage folder doesnt exist.', (t) => {
|
test.serial('If storage path is a empty folder, return metadata with empty folder array and empty note array.', (t) => {
|
||||||
|
const emptyFolderPath = path.join(__dirname, '..', 'dummy/empty')
|
||||||
|
const dummyRawStorage = {
|
||||||
|
name: 'test2',
|
||||||
|
key: crypto.randomBytes(6).toString('hex'),
|
||||||
|
path: emptyFolderPath
|
||||||
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(function before () {
|
.then(function before () {
|
||||||
localStorage.setItem('storages', JSON.stringify([dummyRawStorage]))
|
localStorage.setItem('storages', JSON.stringify([dummyRawStorage]))
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
{"notes":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"tags": [],
|
|
||||||
"title": "Footnote test",
|
|
||||||
"content": "# Footnote test\n\ntest test",
|
|
||||||
"type": "MARKDOWN_NOTE",
|
|
||||||
"folder": "fc6ba88e8ecf",
|
|
||||||
"key": "93c6ac2a7953",
|
|
||||||
"isStarred": false,
|
|
||||||
"createdAt": "2016-07-25T16:19:55.620Z",
|
|
||||||
"updatedAt": "2016-07-26T08:00:11.326Z",
|
|
||||||
"uniqueKey": "1714d46e36b5-fc6ba88e8ecf-93c6ac2a7953"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tags": [],
|
|
||||||
"title": "Checkbox test",
|
|
||||||
"content": "# Checkbox test\n\n- [x] Task1\n- [ ] Task2\n- [ ] Task3\n\n",
|
|
||||||
"type": "MARKDOWN_NOTE",
|
|
||||||
"folder": "fc6ba88e8ecf",
|
|
||||||
"key": "4568d84331d9",
|
|
||||||
"isStarred": false,
|
|
||||||
"createdAt": "2016-07-25T16:58:43.685Z",
|
|
||||||
"updatedAt": "2016-08-21T06:14:50.381Z",
|
|
||||||
"uniqueKey": "1714d46e36b5-fc6ba88e8ecf-4568d84331d9"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
9
tests/dummy/dummyStorage/boostnote.json
Normal file
9
tests/dummy/dummyStorage/boostnote.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"key": "fc6ba88e8ecf",
|
||||||
|
"name": "test",
|
||||||
|
"color": "#FF5555"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
24
tests/dummy/dummyStorage/fc6ba88e8ecf/data.json
Normal file
24
tests/dummy/dummyStorage/fc6ba88e8ecf/data.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"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