|
| 1 | +package email_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/getfider/fider/app/services/email" |
| 7 | + . "github.com/getfider/fider/app/pkg/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestEncodeSubject_ASCIIOnly(t *testing.T) { |
| 11 | + RegisterT(t) |
| 12 | + |
| 13 | + subject := "Hello World" |
| 14 | + encoded := email.EncodeSubject(subject) |
| 15 | + |
| 16 | + Expect(encoded).Equals("Hello World") |
| 17 | +} |
| 18 | + |
| 19 | +func TestEncodeSubject_WithNonASCII(t *testing.T) { |
| 20 | + RegisterT(t) |
| 21 | + |
| 22 | + subject := "Test ä ö ü" |
| 23 | + encoded := email.EncodeSubject(subject) |
| 24 | + |
| 25 | + // The encoded result should be in RFC 2047 format |
| 26 | + Expect(encoded).ContainsSubstring("=?utf-8?q?") |
| 27 | + Expect(encoded).ContainsSubstring("?=") |
| 28 | +} |
| 29 | + |
| 30 | +func TestEncodeSubject_WithEmoji(t *testing.T) { |
| 31 | + RegisterT(t) |
| 32 | + |
| 33 | + subject := "Hello 👋 World 🌍" |
| 34 | + encoded := email.EncodeSubject(subject) |
| 35 | + |
| 36 | + // The encoded result should be in RFC 2047 format |
| 37 | + Expect(encoded).ContainsSubstring("=?utf-8?q?") |
| 38 | + Expect(encoded).ContainsSubstring("?=") |
| 39 | +} |
| 40 | + |
| 41 | +func TestEncodeSubject_Empty(t *testing.T) { |
| 42 | + RegisterT(t) |
| 43 | + |
| 44 | + subject := "" |
| 45 | + encoded := email.EncodeSubject(subject) |
| 46 | + |
| 47 | + Expect(encoded).Equals("") |
| 48 | +} |
| 49 | + |
| 50 | +func TestEncodeSubject_WithUmlautsAndSpecialChars(t *testing.T) { |
| 51 | + RegisterT(t) |
| 52 | + |
| 53 | + subject := "Öffentliche Ankündigung - Größere Änderungen" |
| 54 | + encoded := email.EncodeSubject(subject) |
| 55 | + |
| 56 | + // The encoded result should be in RFC 2047 format |
| 57 | + Expect(encoded).ContainsSubstring("=?utf-8?q?") |
| 58 | + Expect(encoded).ContainsSubstring("?=") |
| 59 | +} |
0 commit comments