1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

add assertions to addStorage test

check version and folders attribute from resolved data and json
This commit is contained in:
Dick Choi
2016-08-28 00:20:08 +09:00
parent ec96021b00
commit 8d624459d4
2 changed files with 11 additions and 1 deletions

View File

@@ -40,7 +40,8 @@ function addStorage (input) {
return Promise.resolve(newStorage) return Promise.resolve(newStorage)
.then(resolveStorageData) .then(resolveStorageData)
.then(function saveMetadataToLocalStorage () { .then(function saveMetadataToLocalStorage (resolvedStorage) {
newStorage = resolvedStorage
rawStorages.push({ rawStorages.push({
key: newStorage.key, key: newStorage.key,
type: newStorage.type, type: newStorage.type,

View File

@@ -12,6 +12,7 @@ const TestDummy = require('../fixtures/TestDummy')
const sander = require('sander') const sander = require('sander')
const _ = require('lodash') const _ = require('lodash')
const os = require('os') const os = require('os')
const CSON = require('season')
const v1StoragePath = path.join(os.tmpdir(), 'test/addStorage-v1-storage') const v1StoragePath = path.join(os.tmpdir(), 'test/addStorage-v1-storage')
// const legacyStoragePath = path.join(os.tmpdir(), 'test/addStorage-legacy-storage') // const legacyStoragePath = path.join(os.tmpdir(), 'test/addStorage-legacy-storage')
@@ -42,6 +43,8 @@ test.serial('Add Storage', (t) => {
t.is(storage.name, input.name) t.is(storage.name, input.name)
t.is(storage.type, input.type) t.is(storage.type, input.type)
t.is(storage.path, input.path) t.is(storage.path, input.path)
t.is(storage.version, '1.0')
t.is(storage.folders.length, t.context.v1StorageData.json.folders.length)
// Check data.notes // Check data.notes
t.is(notes.length, t.context.v1StorageData.notes.length) t.is(notes.length, t.context.v1StorageData.notes.length)
@@ -54,6 +57,12 @@ test.serial('Add Storage', (t) => {
t.is(cacheData.name, input.name) t.is(cacheData.name, input.name)
t.is(cacheData.type, input.type) t.is(cacheData.type, input.type)
t.is(cacheData.path, input.path) t.is(cacheData.path, input.path)
// Check boostnote.json
let 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)
}) })
}) })