package notify import ( "testing" "github.com/stretchr/testify/assert" ) func TestPruneHTML(t *testing.T) { tests := []struct { name string html string maxLength int expected string }{ {"within limit", "

Hello

", 20, "

Hello

"}, {"exceeds limit", "

Hello world, this is a long text

", 15, "

Hello world,...

"}, {"nested tags", "

Hello world

More text

", 20, "

Hello world

More...

"}, {"html comment stripped", "

Hello

", 20, "

Hello

"}, {"self-closing tag", "

Hello
World

", 8, "

Hello
...

"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { assert.Equal(t, tt.expected, pruneHTML(tt.html, tt.maxLength)) }) } } func TestPruneStringToWord(t *testing.T) { tests := []struct { name string text string maxLength int expected string }{ {"within limit", "hello world", 15, "hello world"}, {"cut at word boundary", "hello world and more", 11, "hello world"}, {"zero length", "hello", 0, ""}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { assert.Equal(t, tt.expected, pruneStringToWord(tt.text, tt.maxLength)) }) } }