diff --git a/tests/lib/boostnoterc/.boostnoterc.all b/tests/lib/boostnoterc/.boostnoterc.all new file mode 100644 index 00000000..2caa2c1a --- /dev/null +++ b/tests/lib/boostnoterc/.boostnoterc.all @@ -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 +} diff --git a/tests/lib/boostnoterc/.boostnoterc.invalid b/tests/lib/boostnoterc/.boostnoterc.invalid new file mode 100644 index 00000000..500327cb --- /dev/null +++ b/tests/lib/boostnoterc/.boostnoterc.invalid @@ -0,0 +1,12 @@ +{ + "editor": { + "keyMap": "vim", + "switchPreview": "BLUR", + "theme": "monokai", + }, + "hotkey": { + "toggleMain": "Control + L" + }, + "listWidth": 135, + "navWidth": 135 +} diff --git a/tests/lib/boostnoterc/.boostnoterc.valid b/tests/lib/boostnoterc/.boostnoterc.valid new file mode 100644 index 00000000..23f50f15 --- /dev/null +++ b/tests/lib/boostnoterc/.boostnoterc.valid @@ -0,0 +1,12 @@ +{ + "editor": { + "keyMap": "vim", + "switchPreview": "BLUR", + "theme": "monokai" + }, + "hotkey": { + "toggleMain": "Control + L" + }, + "listWidth": 135, + "navWidth": 135 +} diff --git a/tests/lib/rc-parser-test.js b/tests/lib/rc-parser-test.js new file mode 100644 index 00000000..29d0cdd2 --- /dev/null +++ b/tests/lib/rc-parser-test.js @@ -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) +}