Yimaru-BackEnd/internal/services/chapa/customization_test.go
Yared Yemane 6423bb261e Sanitize Chapa checkout customization text for initialize API.
Strip disallowed characters from customization title and description so subscription payments pass Chapa validation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 04:38:55 -07:00

29 lines
781 B
Go

package chapa
import "testing"
func TestSanitizeChapaCustomization(t *testing.T) {
tests := []struct {
in string
want string
}{
{"Subscription: Premium", "Subscription Premium"},
{"New Test Monthly Premium", "New Test Monthly Premium"},
{"IELTS (Prep) / Monthly", "IELTS Prep Monthly"},
{"", "Yimaru subscription"},
}
for _, tc := range tests {
if got := sanitizeChapaCustomization(tc.in); got != tc.want {
t.Fatalf("sanitizeChapaCustomization(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestChapaSubscriptionDescription(t *testing.T) {
got := chapaSubscriptionDescription("New Test Monthly Premium")
want := "Subscription New Test Monthly Premium"
if got != want {
t.Fatalf("chapaSubscriptionDescription() = %q, want %q", got, want)
}
}