import Testing
@testable import Models

@Suite("EmailAddress")
struct EmailAddressTests {
	@Test("parses name and address from angle-bracket format")
	func parsesNameAndAddress() {
		let addr = EmailAddress.parse("Alice <alice@example.com>")
		#expect(addr.name == "Alice")
		#expect(addr.address == "alice@example.com")
		#expect(addr.displayName == "Alice")
	}

	@Test("parses bare email address")
	func parsesBareAddress() {
		let addr = EmailAddress.parse("bob@example.com")
		#expect(addr.name == nil)
		#expect(addr.address == "bob@example.com")
		#expect(addr.displayName == "bob@example.com")
	}

	@Test("parses quoted name with angle brackets")
	func parsesQuotedName() {
		let addr = EmailAddress.parse("\"Bob Smith\" <bob@example.com>")
		#expect(addr.name == "Bob Smith")
		#expect(addr.address == "bob@example.com")
	}

	@Test("handles empty string gracefully")
	func handlesEmpty() {
		let addr = EmailAddress.parse("")
		#expect(addr.address == "")
	}
}
