1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00
Files
Boostnote/tests/lib/markdown-text-helper-test.js
Shenghan Chen 0f232b3d86 FIX #2853 Allow "#" in title
- Only strip the leading # in the title
- Make the finding title logic more straightforward
- Add unit test
2019-02-04 20:07:33 +13:00

48 lines
1.1 KiB
JavaScript

/**
* @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'],
// Don't remove underscore
['`MY_TITLE`', 'MY_TITLE'],
['MY_TITLE', 'MY_TITLE'],
// I have no idea for it...
['```test', '`test'],
['# C# Features', 'C# Features']
]
testCases.forEach(testCase => {
const [input, expected] = testCase
t.is(markdown.strip(input), expected, `Test for strip() input: ${input} expected: ${expected}`)
})
})