photoprism/pkg/txt/slug_test.go

32 lines
743 B
Go
Raw Normal View History

2020-04-28 17:03:37 +02:00
package txt
import (
"testing"
2020-11-21 18:08:41 +01:00
"github.com/stretchr/testify/assert"
2020-04-28 17:03:37 +02:00
)
2021-09-23 23:46:17 +02:00
func TestSlug(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
assert.Equal(t, "", Slug(""))
})
t.Run("BillGates", func(t *testing.T) {
assert.Equal(t, "william-henry-gates-iii", Slug("William Henry Gates III"))
})
t.Run("Quotes", func(t *testing.T) {
assert.Equal(t, "william-henry-gates", Slug("william \"HenRy\" gates' "))
})
t.Run("Chinese", func(t *testing.T) {
assert.Equal(t, "chen-zhao", Slug(" 陈 赵"))
})
}
2020-04-28 17:03:37 +02:00
func TestSlugToTitle(t *testing.T) {
t.Run("cute_Kitten", func(t *testing.T) {
assert.Equal(t, "Cute-Kitten", SlugToTitle("cute-kitten"))
})
2020-04-28 17:25:14 +02:00
t.Run("empty", func(t *testing.T) {
assert.Equal(t, "", SlugToTitle(""))
})
2020-04-28 17:03:37 +02:00
}