package util_test import ( "testing" "github.com/grafana/grafana/pkg/util" ) func TestIsSvg(t *testing.T) { t.Parallel() tests := map[string]struct { input string expected bool }{ "empty": {"", false}, "html page": {"", false}, "html page with DOCTYPE": {"", false}, "empty svg": {"", true}, "svg with attributes": {"", true}, "svg with content": {"", true}, "svg with attributes and content": {"", true}, "svg with comments": {"", true}, "svg with doctype": {"", true}, "svg with xml declaration": {"", true}, "realistic svg": {` Hello `, true}, } for name, test := range tests { t.Run(name, func(t *testing.T) { t.Parallel() result := util.IsSVG([]byte(test.input)) if result != test.expected { t.Errorf("expected IsSVG to return %v, got %v", test.expected, result) } }) } }