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("

Hi

", "Hi", "https://example.com/unsubscribe?token=abc") if !HasUnsubscribeFooter(html) { t.Fatalf("missing footer in %s", html) } if plain == "" { t.Fatal("plain empty") } }