package mailhtml import ( "strings" "testing" ) func TestFromTextKeepsLineStructure(t *testing.T) { got := FromText("Hi Ana,\n\nQuick question about your team.") want := "
Hi Ana,

Quick question about your team.
" if got != want { t.Errorf("FromText =\n%q\nwant\n%q", got, want) } } func TestFromTextIsEmptyForEmptyInput(t *testing.T) { for _, in := range []string{"", " ", "\n\n", "\r\n"} { if got := FromText(in); got != "" { t.Errorf("FromText(%q) = %q, want an empty body so nothing ships an HTML part", in, got) } } } // The plain body is untrusted template text: it may contain angle brackets, // ampersands, or a merge field someone pasted markup into. func TestFromTextEscapes(t *testing.T) { got := FromText(`Tom & Jerry `) if strings.Contains(got, "