0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-23 16:50:39 +00:00
wp-plugin-go/template/functions_test.go

69 lines
1.1 KiB
Go
Raw Normal View History

2024-03-11 08:23:17 +00:00
package template
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToSentence(t *testing.T) {
tests := []struct {
name string
input string
want string
}{
{
name: "empty string",
input: "",
want: "",
},
{
name: "sentence without end period",
input: "this is a sentence",
want: "This is a sentence.",
},
{
name: "sentence with end period",
input: "this is a sentence.",
want: "This is a sentence.",
},
{
name: "single word",
input: "word",
want: "Word.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := ToSentence(tt.input)
assert.Equal(t, got, tt.want)
})
}
}
func TestLoadFuncMap(t *testing.T) {
tests := []struct {
name string
want []string
wantDiff int
}{
{
name: "valid",
want: []string{
"ToSentence",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := LoadFuncMap()
_, ok := got["ToSentence"]
assert.True(t, ok, "LoadFuncMap() missing ToSentence func")
})
}
}