mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-04 06:22:35 +00:00
Use cases.Title and replace - and _ with spaces
This commit is contained in:
committed by
Manuel Rüger
parent
6d81045bf0
commit
ff677a8690
@@ -33,6 +33,30 @@ func TestSetTitleFromFilename(t *testing.T) {
|
||||
t.Run("set title from filename", func(t *testing.T) {
|
||||
meta := &Meta{Title: ""}
|
||||
setTitleFromFilename(meta, "/path/to/test.md")
|
||||
assert.Equal(t, "test", meta.Title)
|
||||
assert.Equal(t, "Test", meta.Title)
|
||||
})
|
||||
|
||||
t.Run("replace underscores with spaces", func(t *testing.T) {
|
||||
meta := &Meta{Title: ""}
|
||||
setTitleFromFilename(meta, "/path/to/test_with_underscores.md")
|
||||
assert.Equal(t, "Test With Underscores", meta.Title)
|
||||
})
|
||||
|
||||
t.Run("replace dashes with spaces", func(t *testing.T) {
|
||||
meta := &Meta{Title: ""}
|
||||
setTitleFromFilename(meta, "/path/to/test-with-dashes.md")
|
||||
assert.Equal(t, "Test With Dashes", meta.Title)
|
||||
})
|
||||
|
||||
t.Run("mixed underscores and dashes", func(t *testing.T) {
|
||||
meta := &Meta{Title: ""}
|
||||
setTitleFromFilename(meta, "/path/to/test_with-mixed_separators.md")
|
||||
assert.Equal(t, "Test With Mixed Separators", meta.Title)
|
||||
})
|
||||
|
||||
t.Run("already title cased", func(t *testing.T) {
|
||||
meta := &Meta{Title: ""}
|
||||
setTitleFromFilename(meta, "/path/to/Already-Title-Cased.md")
|
||||
assert.Equal(t, "Already Title Cased", meta.Title)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user