package emails import ( "strings" "testing" "github.com/stretchr/testify/assert" ) func TestFormatEventPayloadIndentsAndHighlightsJSON(t *testing.T) { payload := `{"message":"hello","count":2,"ratio":1.5,"enabled":true,"disabled":false,"missing":null,"nested":{"value":"ok"}}` plain, rich := formatEventPayload(payload) html := string(rich) assert.Equal(t, `{ "message": "hello", "count": 2, "ratio": 1.5, "enabled": true, "disabled": false, "missing": null, "nested": { "value": "ok" } }`, plain) assert.Contains(t, html, `"message"`) assert.Contains(t, html, `"hello"`) assert.Contains(t, html, `2`) assert.Contains(t, html, `1.5`) assert.Contains(t, html, `true`) assert.Contains(t, html, `false`) assert.Contains(t, html, `null`) assert.Contains(t, html, `white-space:pre-wrap`) } func TestFormatEventPayloadEscapesPayloadHTML(t *testing.T) { plain, rich := formatEventPayload(`{"message":"&"}`) html := string(rich) assert.Contains(t, plain, `