package domain import "testing" func TestIsValidHexColor(t *testing.T) { cases := map[string]bool{ "": true, // clears the field "#22c55e": true, "#22C55E": true, "#abc": true, "#abcd": true, "#aabbccdd": true, "22c55e": false, // missing # "#": false, "#xyz": false, "#aabbccddee": false, // too long "#ab": false, // too short "rgb(0,0,0)": false, } for in, want := range cases { if got := IsValidHexColor(in); got != want { t.Errorf("IsValidHexColor(%q) = %v, want %v", in, got, want) } } } func TestIsAllowedFont(t *testing.T) { for _, ok := range []string{"", "Inter", "Playfair Display"} { if !IsAllowedFont(ok) { t.Errorf("expected %q to be allowed", ok) } } for _, bad := range []string{"Comic Sans", "Arial", "javascript:alert(1)"} { if IsAllowedFont(bad) { t.Errorf("expected %q to be rejected", bad) } } }