mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-16 03:06:27 +00:00
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"amaEnabled": true,
|
||||||
"editor": {
|
"editor": {
|
||||||
"fontFamily": "Monaco, Consolas",
|
"fontFamily": "Monaco, Consolas",
|
||||||
"fontSize": "14",
|
"fontSize": "14",
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import sander from 'sander'
|
import sander from 'sander'
|
||||||
|
|
||||||
function parse () {
|
const BOOSTNOTERC = '.boostnoterc'
|
||||||
const BOOSTNOTERC = '.boostnoterc'
|
const homePath = global.process.env.HOME || global.process.env.USERPROFILE
|
||||||
const homePath = global.process.env.HOME || global.process.env.USERPROFILE
|
const _boostnotercPath = path.join(homePath, BOOSTNOTERC)
|
||||||
const boostnotercPath = path.join(homePath, BOOSTNOTERC)
|
|
||||||
|
|
||||||
|
export function parse (boostnotercPath = _boostnotercPath) {
|
||||||
if (!sander.existsSync(boostnotercPath)) return {}
|
if (!sander.existsSync(boostnotercPath)) return {}
|
||||||
try {
|
try {
|
||||||
return JSON.parse(sander.readFileSync(boostnotercPath).toString())
|
return JSON.parse(sander.readFileSync(boostnotercPath).toString())
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import RcParser from 'browser/main/lib/RcParser'
|
import RcParser from 'browser/lib/RcParser'
|
||||||
|
|
||||||
const OSX = global.process.platform === 'darwin'
|
const OSX = global.process.platform === 'darwin'
|
||||||
const win = global.process.platform === 'win32'
|
const win = global.process.platform === 'win32'
|
||||||
|
|||||||
33
tests/lib/boostnoterc/.boostnoterc.all
Normal file
33
tests/lib/boostnoterc/.boostnoterc.all
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"amaEnabled": true,
|
||||||
|
"editor": {
|
||||||
|
"fontFamily": "Monaco, Consolas",
|
||||||
|
"fontSize": "14",
|
||||||
|
"indentSize": "2",
|
||||||
|
"indentType": "space",
|
||||||
|
"keyMap": "vim",
|
||||||
|
"switchPreview": "BLUR",
|
||||||
|
"theme": "monokai"
|
||||||
|
},
|
||||||
|
"hotkey": {
|
||||||
|
"toggleFinder": "Cmd + Alt + S",
|
||||||
|
"toggleMain": "Cmd + Alt + L"
|
||||||
|
},
|
||||||
|
"isSideNavFolded": false,
|
||||||
|
"listStyle": "DEFAULT",
|
||||||
|
"listWidth": 174,
|
||||||
|
"navWidth": 200,
|
||||||
|
"preview": {
|
||||||
|
"codeBlockTheme": "dracula",
|
||||||
|
"fontFamily": "Lato",
|
||||||
|
"fontSize": "14",
|
||||||
|
"lineNumber": true
|
||||||
|
},
|
||||||
|
"sortBy": "UPDATED_AT",
|
||||||
|
"ui": {
|
||||||
|
"defaultNote": "ALWAYS_ASK",
|
||||||
|
"disableDirectWrite": false,
|
||||||
|
"theme": "default"
|
||||||
|
},
|
||||||
|
"zoom": 1
|
||||||
|
}
|
||||||
12
tests/lib/boostnoterc/.boostnoterc.invalid
Normal file
12
tests/lib/boostnoterc/.boostnoterc.invalid
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"editor": {
|
||||||
|
"keyMap": "vim",
|
||||||
|
"switchPreview": "BLUR",
|
||||||
|
"theme": "monokai",
|
||||||
|
},
|
||||||
|
"hotkey": {
|
||||||
|
"toggleMain": "Control + L"
|
||||||
|
},
|
||||||
|
"listWidth": 135,
|
||||||
|
"navWidth": 135
|
||||||
|
}
|
||||||
12
tests/lib/boostnoterc/.boostnoterc.valid
Normal file
12
tests/lib/boostnoterc/.boostnoterc.valid
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"editor": {
|
||||||
|
"keyMap": "vim",
|
||||||
|
"switchPreview": "BLUR",
|
||||||
|
"theme": "monokai"
|
||||||
|
},
|
||||||
|
"hotkey": {
|
||||||
|
"toggleMain": "Control + L"
|
||||||
|
},
|
||||||
|
"listWidth": 135,
|
||||||
|
"navWidth": 135
|
||||||
|
}
|
||||||
23
tests/lib/get-todo-status-test.js
Normal file
23
tests/lib/get-todo-status-test.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const test = require('ava')
|
||||||
|
const { getTodoStatus } = require('browser/lib/getTodoStatus')
|
||||||
|
|
||||||
|
// Unit test
|
||||||
|
test('getTodoStatus should return a correct hash object', t => {
|
||||||
|
// [input, expected]
|
||||||
|
const testCases = [
|
||||||
|
['', { total: 0, completed: 0 }],
|
||||||
|
['* [ ] a\n', { total: 1, completed: 0 }],
|
||||||
|
['* [ ] a\n* [x] a\n', { total: 2, completed: 1 }],
|
||||||
|
['- [ ] a\n', { total: 1, completed: 0 }],
|
||||||
|
['- [ ] a\n- [x] a\n', { total: 2, completed: 1 }],
|
||||||
|
['+ [ ] a\n', { total: 1, completed: 0 }],
|
||||||
|
['+ [ ] a\n+ [x] a\n', { total: 2, completed: 1 }]
|
||||||
|
]
|
||||||
|
|
||||||
|
testCases.forEach(testCase => {
|
||||||
|
const [input, expected] = testCase
|
||||||
|
t.is(getTodoStatus(input).total, expected.total, `Test for getTodoStatus() input: ${input} expected: ${expected.total}`)
|
||||||
|
t.is(getTodoStatus(input).completed, expected.completed, `Test for getTodoStatus() input: ${input} expected: ${expected.completed}`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
33
tests/lib/rc-parser-test.js
Normal file
33
tests/lib/rc-parser-test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
const test = require('ava')
|
||||||
|
const path = require('path')
|
||||||
|
const { parse } = require('browser/lib/RcParser')
|
||||||
|
|
||||||
|
// Unit test
|
||||||
|
test('RcParser should return a json object', t => {
|
||||||
|
const validJson = { 'editor': { 'keyMap': 'vim', 'switchPreview': 'BLUR', 'theme': 'monokai' }, 'hotkey': { 'toggleMain': 'Control + L' }, 'listWidth': 135, 'navWidth': 135 }
|
||||||
|
const allJson = { 'amaEnabled': true, 'editor': { 'fontFamily': 'Monaco, Consolas', 'fontSize': '14', 'indentSize': '2', 'indentType': 'space', 'keyMap': 'vim', 'switchPreview': 'BLUR', 'theme': 'monokai' }, 'hotkey': { 'toggleFinder': 'Cmd + Alt + S', 'toggleMain': 'Cmd + Alt + L' }, 'isSideNavFolded': false, 'listStyle': 'DEFAULT', 'listWidth': 174, 'navWidth': 200, 'preview': { 'codeBlockTheme': 'dracula', 'fontFamily': 'Lato', 'fontSize': '14', 'lineNumber': true }, 'sortBy': 'UPDATED_AT', 'ui': { 'defaultNote': 'ALWAYS_ASK', 'disableDirectWrite': false, 'theme': 'default' }, 'zoom': 1 }
|
||||||
|
|
||||||
|
// [input, expected]
|
||||||
|
const validTestCases = [
|
||||||
|
['.boostnoterc.valid', validJson],
|
||||||
|
['.boostnoterc.all', allJson]
|
||||||
|
]
|
||||||
|
|
||||||
|
const invalidTestCases = [
|
||||||
|
['.boostnoterc.invalid', {}]
|
||||||
|
]
|
||||||
|
|
||||||
|
validTestCases.forEach(validTestCase => {
|
||||||
|
const [input, expected] = validTestCase
|
||||||
|
t.is(parse(filePath(input)).editor.keyMap, expected.editor.keyMap, `Test for getTodoStatus() input: ${input} expected: ${expected.keyMap}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
invalidTestCases.forEach(invalidTestCase => {
|
||||||
|
const [input, expected] = invalidTestCase
|
||||||
|
t.is(parse(filePath(input)).editor, expected.editor, `Test for getTodoStatus() input: ${input} expected: ${expected.editor}`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function filePath (filename) {
|
||||||
|
return path.join('boostnoterc', filename)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user