Backend: Add tests to pkg/txt

This commit is contained in:
Theresa Gresch 2020-04-28 17:03:37 +02:00
parent a7c32cd869
commit a384235022
3 changed files with 36 additions and 2 deletions

12
pkg/txt/slug_test.go Normal file
View file

@ -0,0 +1,12 @@
package txt
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSlugToTitle(t *testing.T) {
t.Run("cute_Kitten", func(t *testing.T) {
assert.Equal(t, "Cute-Kitten", SlugToTitle("cute-kitten"))
})
}

View file

@ -55,10 +55,25 @@ func TestUcFirst(t *testing.T) {
}
func TestTitle(t *testing.T) {
t.Run("photo-lover", func(t *testing.T) {
t.Run("Browse your life in pictures", func(t *testing.T) {
assert.Equal(t, "Browse Your Life In Pictures", Title("Browse your life in pictures"))
})
t.Run("cat", func(t *testing.T) {
t.Run("photo-lover", func(t *testing.T) {
assert.Equal(t, "Photo-Lover", Title("photo-lover"))
})
}
func TestBool(t *testing.T) {
t.Run("not empty", func(t *testing.T) {
assert.Equal(t, true, Bool("Browse your life in pictures"))
})
t.Run("no", func(t *testing.T) {
assert.Equal(t, false, Bool("no"))
})
t.Run("false", func(t *testing.T) {
assert.Equal(t, false, Bool("false"))
})
t.Run("empty", func(t *testing.T) {
assert.Equal(t, false, Bool(""))
})
}

View file

@ -17,6 +17,13 @@ func TestWords(t *testing.T) {
})
}
func TestReplaceSpaces(t *testing.T) {
t.Run("I love Cats", func(t *testing.T) {
result := ReplaceSpaces("I love Cats", "dog")
assert.Equal(t, "IdoglovedogCats", result)
})
}
func TestFilenameWords(t *testing.T) {
t.Run("I'm a lazy-brown fox!", func(t *testing.T) {
result := FilenameWords("I'm a lazy-BRoWN fox!")