TF-2613 Add validate same domain method & unit test

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2024-02-29 10:20:02 +07:00
committed by Dat H. Pham
parent 9473599238
commit ae54ca3aad
2 changed files with 45 additions and 1 deletions
@@ -0,0 +1,33 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
void main() {
group('EmailUtils', () {
test('isSameDomain should return true when email is from the same domain as server', () {
String emailAddress = 'user@example.com';
String serverDomain = 'example.com';
bool result = EmailUtils.isSameDomain(emailAddress: emailAddress, serverDomain: serverDomain);
expect(result, true);
});
test('isSameDomain should return false when email is not from the same domain as server', () {
String emailAddress = 'user@example.com';
String serverDomain = 'example2.com';
bool result = EmailUtils.isSameDomain(emailAddress: emailAddress, serverDomain: serverDomain);
expect(result, false);
});
test('isSameDomain should return false when email is invalid', () {
String emailAddress = 'invalid_email';
String serverDomain = 'example.com';
bool result = EmailUtils.isSameDomain(emailAddress: emailAddress, serverDomain: serverDomain);
expect(result, false);
});
});
}