mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
add: cut out trimming text logic for md note title and add unit test
This commit is contained in:
41
tests/lib/markdown-text-helper-test.js
Normal file
41
tests/lib/markdown-text-helper-test.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @fileoverview Unit test for browser/lib/markdown
|
||||
*/
|
||||
const test = require('ava')
|
||||
const markdown = require('browser/lib/markdownTextHelper')
|
||||
|
||||
test(t => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
// List
|
||||
[' - ', ' '],
|
||||
[' + ', ' '],
|
||||
[' * ', ' '],
|
||||
[' * ', ' '],
|
||||
[' 1. ', ' '],
|
||||
[' 2. ', ' '],
|
||||
[' 10. ', ' '],
|
||||
["\t- ", "\t"],
|
||||
['- ', ''],
|
||||
// Header with using line
|
||||
["\n==", "\n"],
|
||||
["\n===", "\n"],
|
||||
["test\n===", "test\n"],
|
||||
// Code block
|
||||
["```test\n", ''],
|
||||
["```test\nhoge", 'hoge'],
|
||||
// HTML tag
|
||||
['<>', ''],
|
||||
['<test>', 'test'],
|
||||
['hoge<test>', 'hogetest'],
|
||||
['<test>moge', 'testmoge'],
|
||||
// Emphasis
|
||||
['~~', ''],
|
||||
['~~text~~', 'text'],
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase;
|
||||
t.is(markdown.strip(input), expected, `Test for strip() input: ${input} expected: ${expected}`);
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user