package emails import ( "html/template" "testing" "github.com/go-hermes/hermes/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestHermesThemeRendersUnsafeDictionaryValueOnlyWhenProvided(t *testing.T) { generator := (&HermesGeneratorConfig{ AppURL: "https://httpsms.com", AppName: "httpSMS", AppLogoURL: "https://httpsms.com/logo.png", }).Generator() email := hermes.Email{ Body: hermes.Body{ Title: "Hello", Dictionary: []hermes.Entry{ {Key: "Normal", Value: "escaped"}, { Key: "Payload", Value: "plain payload", UnsafeValue: template.HTML(`
rich payload`), }, }, }, } htmlEmail, err := generator.GenerateHTML(email) require.NoError(t, err) textEmail, err := generator.GeneratePlainText(email) require.NoError(t, err) assert.Contains(t, htmlEmail, `<b>escaped</b>`) assert.NotContains(t, htmlEmail, `escaped`) assert.Contains(t, htmlEmail, `
rich payload`) assert.NotContains(t, htmlEmail, `