package server import ( "strings" "testing" "unicode/utf8" ) func TestReplyNotificationKeepsParagraphs(t *testing.T) { got := paragraphs(" First line \r\n\r\n\n\n Second paragraph \nthird\x00 line\n\n") if want := "First line\n\nSecond paragraph\nthird line"; got != want { t.Fatalf("paragraphs = %q, want %q", got, want) } _, body := chatReplyText("Chat", "One\n\nTwo") if body != "One\n\nTwo" { t.Fatalf("app body should keep paragraph breaks, got %q", body) } // ntfy gets the same text on one line. if flat := singleLine(body); strings.Contains(flat, "\n") || flat != "One Two" { t.Fatalf("ntfy body = %q", flat) } long := truncateRunes(strings.Repeat("a", 1500), chatReplyBodyRunes) if n := utf8.RuneCountInString(long); n != chatReplyBodyRunes+1 || chatReplyBodyRunes != 1000 { t.Fatalf("excerpt is %d runes (limit %d)", n, chatReplyBodyRunes) } }