weiro/models/categories_test.go

29 lines
596 B
Go
Raw Permalink Normal View History

package models_test
import (
"testing"
"github.com/stretchr/testify/assert"
"lmika.dev/lmika/weiro/models"
)
func TestGenerateCategorySlug(t *testing.T) {
tests := []struct {
name string
want string
}{
{"Go Programming", "go-programming"},
{" Travel ", "travel"},
{"hello---world", "hello-world"},
{"UPPER CASE", "upper-case"},
{"one", "one"},
{"with_underscores", "with-underscores"},
{"special!@#chars", "specialchars"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, models.GenerateCategorySlug(tt.name))
})
}
}