Files
Mathias Gisch 6c1c94c637 Added Email parsing
Added Emailaddress conversion from addesses in the form "test@xample.com>"
2026-02-27 16:28:40 +01:00

31 lines
1.1 KiB
Swift

import Testing
import SwiftMail
@Suite("EmailAddress Tests")
struct EmailAddressTests {
@Test("Email address formatting without name")
func testFormattingWithoutName() throws {
let email = EmailAddress(address: "test@example.com")
#expect(email.description == "test@example.com")
}
@Test("Email address formatting with simple name")
func testFormattingWithSimpleName() throws {
let email = EmailAddress(name: "John Doe", address: "john@example.com")
#expect(email.description == "John Doe <john@example.com>")
}
@Test("Email address formatting with name containing special characters")
func testFormattingWithSpecialCharsInName() throws {
let email = EmailAddress(name: "John Doe, Jr.", address: "john@example.com")
#expect(email.description == "\"John Doe, Jr.\" <john@example.com>")
}
@Test("Email address parsing without name")
func testParsingWithoutName() throws {
let email = EmailAddress("<test@example.com>")
let validEmail = try #require(email)
#expect(validEmail.description == "test@example.com")
}
}