// SPDX-License-Identifier: AGPL-3.0-or-later package mail import ( "strings" "testing" ) func TestRender(t *testing.T) { m, err := Render("a@b.test", "test", map[string]string{"AppName": "Acme "}) if err != nil { t.Fatal(err) } if m.To != "a@b.test" || m.Subject != "Acme test email" { t.Errorf("to/subject = %q / %q", m.To, m.Subject) } if !strings.Contains(m.HTML, "Acme <Wiki>") { t.Errorf("html must escape the app name: %s", m.HTML) } if strings.Contains(m.Text, "test email\n") || !strings.HasPrefix(m.Text, "This is a test email") { t.Errorf("text must not repeat the subject: %q", m.Text) } }