TF-3349 Escape messages when forward and reply email
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/extensions/email_address_extension.dart';
|
||||
|
||||
void main() {
|
||||
group('EmailAddressExtension::asFullStringWithLtGtCharacter::', () {
|
||||
test('Should returns displayName and emailAddress formatted correctly', () {
|
||||
final emailAddress = EmailAddress(
|
||||
'john doe',
|
||||
'john.doe@example.com',
|
||||
);
|
||||
expect(
|
||||
emailAddress.asFullStringWithLtGtCharacter(),
|
||||
'John Doe <john.doe@example.com>',
|
||||
);
|
||||
});
|
||||
|
||||
test('Should returns displayName capitalized when emailAddress is empty', () {
|
||||
final emailAddress = EmailAddress(
|
||||
'jane doe',
|
||||
'',
|
||||
);
|
||||
expect(emailAddress.asFullStringWithLtGtCharacter(), 'Jane Doe');
|
||||
});
|
||||
|
||||
test('Should returns emailAddress enclosed in <> when displayName is empty', () {
|
||||
final emailAddress = EmailAddress(
|
||||
'',
|
||||
'jane.doe@example.com',
|
||||
);
|
||||
expect(emailAddress.asFullStringWithLtGtCharacter(), '<jane.doe@example.com>');
|
||||
});
|
||||
|
||||
test('Should returns an empty string when both displayName and emailAddress are empty', () {
|
||||
final emailAddress = EmailAddress('', '');
|
||||
expect(emailAddress.asFullStringWithLtGtCharacter(), '');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/extensions/list_email_address_extension.dart';
|
||||
|
||||
void main() {
|
||||
group('ListEmailAddressExtension::toEscapeHtmlString::', () {
|
||||
test('Should returns empty string for null or empty list', () {
|
||||
expect((<EmailAddress>{}).toEscapeHtmlString(', '), '');
|
||||
|
||||
Set<EmailAddress>? listEmails;
|
||||
expect(listEmails.toEscapeHtmlString(', '), '');
|
||||
});
|
||||
|
||||
test('Should returns joined HTML strings with separator', () {
|
||||
final emails = {
|
||||
EmailAddress('John Doe', 'john@example.com'),
|
||||
EmailAddress('Jane Smith', 'jane@example.com'),
|
||||
};
|
||||
final result = emails.toEscapeHtmlString(' | ');
|
||||
|
||||
expect(result, 'John Doe <john@example.com> | Jane Smith <jane@example.com>');
|
||||
});
|
||||
|
||||
test('Should handles displayName-only or email-only cases', () {
|
||||
final emails = {
|
||||
EmailAddress('John Doe', ''),
|
||||
EmailAddress('', 'jane@example.com'),
|
||||
};
|
||||
final result = emails.toEscapeHtmlString(', ');
|
||||
|
||||
expect(result, 'John Doe, <jane@example.com>');
|
||||
});
|
||||
});
|
||||
|
||||
group('ListEmailAddressExtension::toEscapeHtmlStringUseCommaSeparator::', () {
|
||||
test('Should uses ", " as separator', () {
|
||||
final emails = {
|
||||
EmailAddress('John Doe', 'john@example.com'),
|
||||
EmailAddress('Jane Smith', 'jane@example.com'),
|
||||
};
|
||||
final result = emails.toEscapeHtmlStringUseCommaSeparator();
|
||||
|
||||
expect(result, 'John Doe <john@example.com>, Jane Smith <jane@example.com>');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user