-
Notifications
You must be signed in to change notification settings - Fork 75
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
e7a480b
commit 89f6db4
Showing
4 changed files
with
160 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,12 @@ void main() { | |
"संपर्क@डाटामेल.भारत" | ||
]; | ||
|
||
final List<String> goodSubAddresses = [ | ||
"[email protected]", | ||
"user+my [email protected]", | ||
"user+Dossier d'été@domain.com" | ||
]; | ||
|
||
group('MailAddress simple test', () { | ||
test('MailAddress.validateAddress() should be return MailAddress when address valid', () { | ||
MailAddress mailAddress = MailAddress.validateAddress('[email protected]'); | ||
|
@@ -165,5 +171,49 @@ void main() { | |
final mailAddress = MailAddress.validateAddress(GOOD_ADDRESS); | ||
expect(mailAddress.toString(), equals(GOOD_ADDRESS)); | ||
}); | ||
|
||
group('MailAddress.validateAddress() should not throw any exceptions with the list of good subaddress', () { | ||
for (var arg in goodSubAddresses) { | ||
test(arg, () { | ||
expect(() => MailAddress.validateAddress(arg), returnsNormally); | ||
}); | ||
} | ||
}); | ||
|
||
test('MailAddress.encodeLocalPartDetails() should work with characters to encode', () { | ||
final mailAddress = MailAddress.validateAddress("user+my [email protected]"); | ||
expect(mailAddress.asStringWithEncodedLocalPartDetails(), equals("user+my%[email protected]")); | ||
}); | ||
|
||
test('MailAddress.encodeLocalPartDetails() should work with many characters to encode', () { | ||
final mailAddress = MailAddress.validateAddress("user+Dossier d'été@domain.com"); | ||
expect(mailAddress.asStringWithEncodedLocalPartDetails(), equals("user+Dossier%20d%27%C3%A9t%C3%[email protected]")); | ||
}); | ||
|
||
test('getLocalPartDetails() should work', () { | ||
final mailAddress = MailAddress.validateAddress("[email protected]"); | ||
expect(mailAddress.getLocalPartDetails(), equals("details")); | ||
}); | ||
|
||
test('getLocalPartWithoutDetails() should work', () { | ||
final mailAddress = MailAddress.validateAddress("[email protected]"); | ||
expect(mailAddress.getLocalPartWithoutDetails(), equals("user")); | ||
}); | ||
|
||
test('stripDetails() should work', () { | ||
final mailAddress = MailAddress.validateAddress("[email protected]"); | ||
expect(mailAddress.stripDetails().asString(), equals("[email protected]")); | ||
}); | ||
|
||
test('stripDetails() should work with encoded local part', () { | ||
final mailAddress = MailAddress.validateAddress("user+Dossier%20d%27%C3%A9t%C3%[email protected]"); | ||
expect(mailAddress.stripDetails().asString(), equals("[email protected]")); | ||
}); | ||
|
||
test('stripDetails() should work when local part needs encoding', () { | ||
final mailAddress = MailAddress.validateAddress("user+super [email protected]"); | ||
expect(mailAddress.stripDetails().asString(), equals("[email protected]")); | ||
}); | ||
|
||
}); | ||
} |
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