package account import ( "strings" "testing" ) // TestRenderConfirmationEmail checks that each (purpose, locale) renders a localised // subject, embeds the code and the one-tap deeplink in both bodies, and produces HTML. func TestRenderConfirmationEmail(t *testing.T) { const deeplink = "https://erudit-game.ru/app/#/confirm/tok123" cases := []struct { name, purpose, locale, subjectSub string }{ {"login ru", purposeLogin, "ru", "вход"}, {"login en", purposeLogin, "en", "sign-in"}, {"link ru", purposeLink, "ru", "подтвержд"}, {"link en", purposeLink, "en", "confirmation"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { msg, err := renderConfirmationEmail(c.purpose, "123456", deeplink, "https://erudit-game.ru", c.locale) if err != nil { t.Fatalf("render: %v", err) } if !strings.Contains(strings.ToLower(msg.Subject), c.subjectSub) { t.Errorf("subject %q does not contain %q", msg.Subject, c.subjectSub) } if !strings.Contains(msg.Text, "123456") || !strings.Contains(msg.HTML, "123456") { t.Error("code missing from a body") } if !strings.Contains(msg.Text, deeplink) || !strings.Contains(msg.HTML, "confirm/tok123") { t.Error("deeplink missing from a body") } if !strings.Contains(msg.HTML, "