forked from Enough-Software/enough_mail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cec51a5
commit 4acff84
Showing
4 changed files
with
2 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,158 +114,6 @@ void main() { | |
); | ||
//print(message.renderMessage()); | ||
}); | ||
|
||
test('Simple chat message', () { | ||
const from = MailAddress('Personal Name', '[email protected]'); | ||
final to = [ | ||
const MailAddress('Recipient Personal Name', '[email protected]'), | ||
]; | ||
const subject = 'Hello from test'; | ||
const text = | ||
'Hello World - here\'s some text that should spans two lines in the ' | ||
'end when this sentence is finished.'; | ||
final message = MessageBuilder.buildSimpleTextMessage( | ||
from, | ||
to, | ||
text, | ||
subject: subject, | ||
isChat: true, | ||
); | ||
expect(message.getHeaderValue('subject'), 'Hello from test'); | ||
var id = message.getHeaderValue('message-id') ?? ''; | ||
expect(id, isNotNull); | ||
expect(id.startsWith('<chat\$'), isTrue); | ||
expect(message.getHeaderValue('date'), isNotNull); | ||
expect( | ||
message.getHeaderValue('from'), | ||
'"Personal Name" <[email protected]>', | ||
); | ||
expect( | ||
message.getHeaderValue('to'), | ||
'"Recipient Personal Name" <[email protected]>', | ||
); | ||
expect( | ||
message.getHeaderValue('Content-Type'), | ||
'text/plain; charset="utf-8"', | ||
); | ||
expect( | ||
message.getHeaderValue('Content-Transfer-Encoding'), | ||
'quoted-printable', | ||
); | ||
|
||
final messageText = message.renderMessage(); | ||
//print(messageText); | ||
final parsed = MimeMessage.parseFromText(messageText); | ||
|
||
expect(parsed.getHeaderValue('subject'), 'Hello from test'); | ||
id = parsed.getHeaderValue('message-id') ?? ''; | ||
expect(id, isNotNull); | ||
expect(id.startsWith('<chat\$'), isTrue); | ||
expect(parsed.getHeaderValue('date'), isNotNull); | ||
expect( | ||
parsed.getHeaderValue('from'), | ||
'"Personal Name" <[email protected]>', | ||
); | ||
expect( | ||
parsed.getHeaderValue('to'), | ||
'"Recipient Personal Name" <[email protected]>', | ||
); | ||
expect( | ||
parsed.getHeaderValue('Content-Type'), | ||
'text/plain; charset="utf-8"', | ||
); | ||
expect( | ||
parsed.getHeaderValue('Content-Transfer-Encoding'), | ||
'quoted-printable', | ||
); | ||
expect( | ||
parsed.decodeContentText(), | ||
'Hello World - here\'s some text that should spans two lines in the ' | ||
'end when this sentence is finished.', | ||
); | ||
}); | ||
|
||
test('Simple chat group message', () { | ||
const from = MailAddress('Personal Name', '[email protected]'); | ||
final to = [ | ||
const MailAddress('Recipient Personal Name', '[email protected]'), | ||
const MailAddress('Other Recipient', '[email protected]'), | ||
]; | ||
const subject = 'Hello from test'; | ||
const text = | ||
'Hello World - here\s some text that should spans two lines in the ' | ||
'end when this sentence is finished.'; | ||
final message = MessageBuilder.buildSimpleTextMessage( | ||
from, | ||
to, | ||
text, | ||
subject: subject, | ||
isChat: true, | ||
chatGroupId: '1234abc123', | ||
); | ||
expect(message.getHeaderValue('subject'), 'Hello from test'); | ||
var id = message.getHeaderValue('message-id') ?? ''; | ||
expect(id, isNotNull); | ||
expect(id.startsWith('<chat\$group.1234abc123.'), isTrue); | ||
expect(message.getHeaderValue('date'), isNotNull); | ||
expect( | ||
message.getHeaderValue('from'), | ||
'"Personal Name" <[email protected]>', | ||
); | ||
expect( | ||
message.getHeaderValue('to'), | ||
'"Recipient Personal Name" <[email protected]>, ' | ||
'"Other Recipient" <[email protected]>', | ||
); | ||
expect( | ||
message.getHeaderValue('Content-Type'), | ||
'text/plain; charset="utf-8"', | ||
); | ||
expect( | ||
message.getHeaderValue('Content-Transfer-Encoding'), | ||
'quoted-printable', | ||
); | ||
|
||
final buffer = StringBuffer(); | ||
message.render(buffer); | ||
final messageText = buffer.toString(); | ||
//print(messageText); | ||
final parsed = MimeMessage.parseFromText(messageText); | ||
|
||
expect(parsed.getHeaderValue('subject'), 'Hello from test'); | ||
id = parsed.getHeaderValue('message-id') ?? ''; | ||
expect(id, isNotNull); | ||
expect(id.startsWith('<chat\$group.1234abc123.'), isTrue); | ||
expect(parsed.getHeaderValue('date'), isNotNull); | ||
expect( | ||
parsed.getHeaderValue('from'), | ||
'"Personal Name" <[email protected]>', | ||
); | ||
final toRecipients = parsed.decodeHeaderMailAddressValue('to') ?? []; | ||
expect(toRecipients, isNotNull); | ||
expect(toRecipients.length, 2); | ||
expect(toRecipients[0].email, '[email protected]'); | ||
expect(toRecipients[0].hostName, 'domain.com'); | ||
expect(toRecipients[0].mailboxName, 'recipient'); | ||
expect(toRecipients[0].personalName, 'Recipient Personal Name'); | ||
expect(toRecipients[1].email, '[email protected]'); | ||
expect(toRecipients[1].hostName, 'domain.com'); | ||
expect(toRecipients[1].mailboxName, 'other'); | ||
expect(toRecipients[1].personalName, 'Other Recipient'); | ||
expect( | ||
parsed.getHeaderValue('Content-Type'), | ||
'text/plain; charset="utf-8"', | ||
); | ||
expect( | ||
parsed.getHeaderValue('Content-Transfer-Encoding'), | ||
'quoted-printable', | ||
); | ||
expect( | ||
parsed.decodeContentText(), | ||
'Hello World - here\s some text that should spans two lines in the ' | ||
'end when this sentence is finished.', | ||
); | ||
}); | ||
}); | ||
|
||
group('multipart tests', () { | ||
|