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

fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)

This commit is contained in:
Nguyen Viet Hung
2020-02-05 13:28:27 +13:00
committed by GitHub
parent 051ce9e208
commit 592aca1539
186 changed files with 9233 additions and 5565 deletions

View File

@@ -6,7 +6,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 sander = require('sander')
@@ -16,26 +19,30 @@ const faker = require('faker')
const storagePath = path.join(os.tmpdir(), 'test/create-note')
test.beforeEach((t) => {
test.beforeEach(t => {
t.context.storage = TestDummy.dummyStorage(storagePath)
localStorage.setItem('storages', JSON.stringify([t.context.storage.cache]))
})
test.serial('Create a note', (t) => {
test.serial('Create a note', t => {
const storageKey = t.context.storage.cache.key
const folderKey = t.context.storage.json.folders[0].key
const randLinesHighlightedArray = new Array(10).fill().map(() => Math.round(Math.random() * 10))
const randLinesHighlightedArray = new Array(10)
.fill()
.map(() => Math.round(Math.random() * 10))
const input1 = {
type: 'SNIPPET_NOTE',
description: faker.lorem.lines(),
snippets: [{
name: faker.system.fileName(),
mode: 'text',
content: faker.lorem.lines(),
linesHighlighted: randLinesHighlightedArray
}],
snippets: [
{
name: faker.system.fileName(),
mode: 'text',
content: faker.lorem.lines(),
linesHighlighted: randLinesHighlightedArray
}
],
tags: faker.lorem.words().split(' '),
folder: folderKey
}
@@ -51,18 +58,20 @@ test.serial('Create a note', (t) => {
input2.title = input2.content.split('\n').shift()
return Promise.resolve()
.then(function doTest () {
.then(function doTest() {
return Promise.all([
createNote(storageKey, input1),
createNote(storageKey, input2)
])
})
.then(function assert (data) {
.then(function assert(data) {
const data1 = data[0]
const data2 = data[1]
t.is(storageKey, data1.storage)
const jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
const jsonData1 = CSON.readFileSync(
path.join(storagePath, 'notes', data1.key + '.cson')
)
t.is(input1.title, data1.title)
t.is(input1.title, jsonData1.title)
@@ -76,11 +85,19 @@ test.serial('Create a note', (t) => {
t.is(input1.snippets[0].content, jsonData1.snippets[0].content)
t.is(input1.snippets[0].name, data1.snippets[0].name)
t.is(input1.snippets[0].name, jsonData1.snippets[0].name)
t.deepEqual(input1.snippets[0].linesHighlighted, data1.snippets[0].linesHighlighted)
t.deepEqual(input1.snippets[0].linesHighlighted, jsonData1.snippets[0].linesHighlighted)
t.deepEqual(
input1.snippets[0].linesHighlighted,
data1.snippets[0].linesHighlighted
)
t.deepEqual(
input1.snippets[0].linesHighlighted,
jsonData1.snippets[0].linesHighlighted
)
t.is(storageKey, data2.storage)
const jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
const jsonData2 = CSON.readFileSync(
path.join(storagePath, 'notes', data2.key + '.cson')
)
t.is(input2.title, data2.title)
t.is(input2.title, jsonData2.title)
t.is(input2.content, data2.content)
@@ -92,7 +109,7 @@ test.serial('Create a note', (t) => {
})
})
test.after(function after () {
test.after(function after() {
localStorage.clear()
sander.rimrafSync(storagePath)
})