mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Added preferences to support toggling front matter title extraction on/off and to customize what field is used for the title.
This commit is contained in:
@@ -15,7 +15,32 @@ test('findNoteTitle#find should return a correct title (string)', t => {
|
||||
['====', '===='],
|
||||
['```\n# hoge\n```', '```'],
|
||||
['hoge', 'hoge'],
|
||||
['---\nlayout: test\n---\n # hoge', '# hoge'],
|
||||
['---\nlayout: test\n---\n # hoge', '# hoge']
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(findNoteTitle(input, false), expected, `Test for find() input: ${input} expected: ${expected}`)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should ignore front matter when enableFrontMatterTitle=false', t => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['---\nlayout: test\ntitle: hoge hoge hoge \n---\n# fuga', '# fuga'],
|
||||
['---\ntitle:hoge\n---\n# fuga', '# fuga'],
|
||||
['title: fuga\n# hoge', '# hoge']
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(findNoteTitle(input, false), expected, `Test for find() input: ${input} expected: ${expected}`)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should respect front matter when enableFrontMatterTitle=true', t => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['---\nlayout: test\ntitle: hoge hoge hoge \n---\n# fuga', 'hoge hoge hoge'],
|
||||
['---\ntitle:hoge\n---\n# fuga', 'hoge'],
|
||||
['title: fuga\n# hoge', '# hoge']
|
||||
@@ -23,6 +48,19 @@ test('findNoteTitle#find should return a correct title (string)', t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(findNoteTitle(input), expected, `Test for find() input: ${input} expected: ${expected}`)
|
||||
t.is(findNoteTitle(input, true), expected, `Test for find() input: ${input} expected: ${expected}`)
|
||||
})
|
||||
})
|
||||
|
||||
test('findNoteTitle#find should respect frontMatterTitleField when provided', t => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['---\ntitle: hoge\n---\n# fuga', '# fuga'],
|
||||
['---\ncustom: hoge\n---\n# fuga', 'hoge']
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(findNoteTitle(input, true, 'custom'), expected, `Test for find() input: ${input} expected: ${expected}`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user