mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
Merge branch 'master' into export-yfm
This commit is contained in:
@@ -7,7 +7,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 os = require('os')
|
||||
@@ -17,12 +20,12 @@ const sander = require('sander')
|
||||
|
||||
const storagePath = path.join(os.tmpdir(), 'test/export-note')
|
||||
|
||||
test.beforeEach((t) => {
|
||||
test.beforeEach(t => {
|
||||
t.context.storage = TestDummy.dummyStorage(storagePath)
|
||||
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
|
||||
})
|
||||
|
||||
test.serial('Export a folder', (t) => {
|
||||
test.serial('Export a folder', t => {
|
||||
const storageKey = t.context.storage.cache.key
|
||||
const folderKey = t.context.storage.json.folders[0].key
|
||||
|
||||
@@ -37,11 +40,13 @@ test.serial('Export a folder', (t) => {
|
||||
const input2 = {
|
||||
type: 'SNIPPET_NOTE',
|
||||
description: 'Some normal text',
|
||||
snippets: [{
|
||||
name: faker.system.fileName(),
|
||||
mode: 'text',
|
||||
content: faker.lorem.lines()
|
||||
}],
|
||||
snippets: [
|
||||
{
|
||||
name: faker.system.fileName(),
|
||||
mode: 'text',
|
||||
content: faker.lorem.lines()
|
||||
}
|
||||
],
|
||||
tags: faker.lorem.words().split(' '),
|
||||
folder: folderKey
|
||||
}
|
||||
@@ -56,13 +61,13 @@ test.serial('Export a folder', (t) => {
|
||||
}
|
||||
|
||||
return createNote(storageKey, input1)
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
return createNote(storageKey, input2)
|
||||
})
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
return exportFolder(storageKey, folderKey, 'md', storagePath, config)
|
||||
})
|
||||
.then(function assert () {
|
||||
.then(function assert() {
|
||||
let filePath = path.join(storagePath, 'input1.md')
|
||||
t.true(fs.existsSync(filePath))
|
||||
filePath = path.join(storagePath, 'input2.md')
|
||||
@@ -70,7 +75,7 @@ test.serial('Export a folder', (t) => {
|
||||
})
|
||||
})
|
||||
|
||||
test.after.always(function after () {
|
||||
test.after.always(function after() {
|
||||
localStorage.clear()
|
||||
sander.rimrafSync(storagePath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user