-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-2168 Add unit-test for
parseMapMailtoFromUri
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:tmail_ui_user/main/routes/app_routes.dart'; | ||
import 'package:tmail_ui_user/main/routes/route_utils.dart'; | ||
|
||
void main() { | ||
group('parseMapMailtoFromUri test', () { | ||
test('should parse a valid mailto URI', () { | ||
const mailtoUri = 'mailto:[email protected]?subject=Hello'; | ||
final result = RouteUtils.parseMapMailtoFromUri(mailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals('[email protected]')); | ||
expect(result[RouteUtils.paramSubject], equals('Hello')); | ||
}); | ||
|
||
test('should parse a valid mailto URI encoded', () { | ||
const mailtoUri = 'mailto:test%40example.com%3Fsubject=Hello'; | ||
final result = RouteUtils.parseMapMailtoFromUri(mailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals('[email protected]')); | ||
expect(result[RouteUtils.paramSubject], equals('Hello')); | ||
}); | ||
|
||
test('should handle a mailto URI without subject', () { | ||
const mailtoUri = 'mailto:[email protected]'; | ||
final result = RouteUtils.parseMapMailtoFromUri(mailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals('[email protected]')); | ||
expect(result[RouteUtils.paramSubject], isNull); | ||
}); | ||
|
||
test('should handle a mailto URI without subject encoded', () { | ||
const mailtoUri = 'mailto:test%40example.com'; | ||
final result = RouteUtils.parseMapMailtoFromUri(mailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals('[email protected]')); | ||
expect(result[RouteUtils.paramSubject], isNull); | ||
}); | ||
|
||
test('should handle a non-mailto URI', () { | ||
const nonMailtoUri = '[email protected]'; | ||
final result = RouteUtils.parseMapMailtoFromUri(nonMailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals(nonMailtoUri)); | ||
expect(result[RouteUtils.paramSubject], isNull); | ||
}); | ||
|
||
test('should handle a non-mailto URI encoded', () { | ||
const nonMailtoUri = 'test%40example.com'; | ||
final result = RouteUtils.parseMapMailtoFromUri(nonMailtoUri); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], equals('[email protected]')); | ||
expect(result[RouteUtils.paramSubject], isNull); | ||
}); | ||
|
||
test('should handle null input', () { | ||
final result = RouteUtils.parseMapMailtoFromUri(null); | ||
|
||
expect(result[RouteUtils.paramRouteName], equals(AppRoutes.mailtoURL)); | ||
expect(result[RouteUtils.paramMailtoAddress], isNull); | ||
expect(result[RouteUtils.paramSubject], isNull); | ||
}); | ||
}); | ||
} |