0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-24 03:00:40 +00:00
wp-plugin-go/template/template_test.go

53 lines
763 B
Go
Raw Permalink Normal View History

2024-03-11 08:23:17 +00:00
package template
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAddPrefix(t *testing.T) {
type args struct {
prefix string
input string
}
tests := []struct {
name string
args args
want string
}{
{
name: "empty input",
args: args{
prefix: "pre",
input: "",
},
want: "",
},
{
name: "input already has prefix",
args: args{
prefix: "pre",
input: "pre-existing",
},
want: "pre-existing",
},
{
name: "add prefix",
args: args{
prefix: "pre",
input: "-existing",
},
want: "pre-existing",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := AddPrefix(tt.args.prefix, tt.args.input)
assert.Equal(t, tt.want, got)
})
}
}