1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Merge pull request #548 from asmsuechan/add-a-module-findTitle

Add a module to find the title
This commit is contained in:
SuenagaRyota
2017-06-07 10:30:46 +09:00
committed by GitHub
4 changed files with 62 additions and 68 deletions

View File

@@ -0,0 +1,25 @@
/**
* @fileoverview Unit test for browser/lib/findTitle
*/
const test = require('ava')
const { findNoteTitle } = require('browser/lib/findNoteTitle')
// Unit test
test('findNoteTitle#find should return a correct title (string)', t => {
// [input, expected]
const testCases = [
['# hoge\nfuga', '# hoge'],
['# hoge_hoge_hoge', '# hoge_hoge_hoge'],
['hoge\n====\nfuga', 'hoge'],
['====', '===='],
['```\n# hoge\n```', '```'],
['hoge', 'hoge']
]
testCases.forEach(testCase => {
const [input, expected] = testCase
t.is(findNoteTitle(input), expected, `Test for find() input: ${input} expected: ${expected}`)
})
})