mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 11:37:02 -04:00
refactor: move frontmatter parser into commons package
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4d0a2cb79e
commit
db43e1db3f
26 changed files with 462 additions and 321 deletions
|
@ -3,9 +3,12 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import {
|
||||
NoteFrontmatter,
|
||||
NoteTextDirection,
|
||||
NoteType
|
||||
} from '../note-frontmatter/frontmatter.js'
|
||||
import { generateNoteTitle } from './generate-note-title.js'
|
||||
import { NoteFrontmatter, NoteTextDirection } from './types/frontmatter.js'
|
||||
import { NoteType } from './types/frontmatter.js'
|
||||
import { describe, expect, it } from '@jest/globals'
|
||||
|
||||
const testFrontmatter: NoteFrontmatter = {
|
||||
|
@ -36,7 +39,7 @@ describe('generate note title', () => {
|
|||
title: 'frontmatter',
|
||||
opengraph: { title: 'opengraph' }
|
||||
},
|
||||
'first-heading'
|
||||
() => 'first-heading'
|
||||
)
|
||||
expect(actual).toEqual('frontmatter')
|
||||
})
|
||||
|
@ -44,13 +47,16 @@ describe('generate note title', () => {
|
|||
it('will choose the opengraph title second', () => {
|
||||
const actual = generateNoteTitle(
|
||||
{ ...testFrontmatter, opengraph: { title: 'opengraph' } },
|
||||
'first-heading'
|
||||
() => 'first-heading'
|
||||
)
|
||||
expect(actual).toEqual('opengraph')
|
||||
})
|
||||
|
||||
it('will choose the first heading third', () => {
|
||||
const actual = generateNoteTitle({ ...testFrontmatter }, 'first-heading')
|
||||
const actual = generateNoteTitle(
|
||||
{ ...testFrontmatter },
|
||||
() => 'first-heading'
|
||||
)
|
||||
expect(actual).toEqual('first-heading')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue