Files
descrybe/apps/api/internal/campaigns/templates_test.go
T
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

36 lines
880 B
Go

package campaigns
import "testing"
func TestListTemplates(t *testing.T) {
tpls := ListTemplates()
if len(tpls) != 4 {
t.Fatalf("expected 4 templates, got %d", len(tpls))
}
for _, key := range []string{"christmas", "black_friday", "spring", "custom"} {
if !ValidTemplateKey(key) {
t.Fatalf("expected valid key %s", key)
}
}
}
func TestNormalizeEmail(t *testing.T) {
e, err := NormalizeEmail(" User@Example.COM ")
if err != nil || e != "user@example.com" {
t.Fatalf("got %q err=%v", e, err)
}
if _, err := NormalizeEmail("not-an-email"); err == nil {
t.Fatal("expected error")
}
}
func TestUnsubscribeFooter(t *testing.T) {
html, plain := EnsureUnsubscribeFooter("<p>Hi</p>", "Hi", "https://example.com/unsubscribe?token=abc")
if !HasUnsubscribeFooter(html) {
t.Fatalf("missing footer in %s", html)
}
if plain == "" {
t.Fatal("plain empty")
}
}