-
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.
TF-2528 Add unit test for sortingListEmailByOrderIdList method
Signed-off-by: dab246 <[email protected]>
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
test/features/email/sorting_list_email_by_order_id_list_test.dart
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,54 @@ | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:jmap_dart_client/jmap/core/id.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email.dart'; | ||
import 'package:tmail_ui_user/features/thread/data/extensions/list_email_extension.dart'; | ||
void main() { | ||
group('sorting_list_email_by_order_id_list test', () { | ||
test('sortingByOrderOfIdList method should return an ordered list of ids when of the same length', () { | ||
List<Id> ids = [ | ||
Id('a'), | ||
Id('b'), | ||
Id('c'), | ||
Id('d'), | ||
Id('e') | ||
]; | ||
List<Email> emails = [ | ||
Email(id: EmailId(Id('a'))), | ||
Email(id: EmailId(Id('c'))), | ||
Email(id: EmailId(Id('e'))), | ||
Email(id: EmailId(Id('d'))), | ||
Email(id: EmailId(Id('b'))) | ||
]; | ||
|
||
List<Email> sortedEmails = emails.sortingByOrderOfIdList(ids); | ||
|
||
expect( | ||
sortedEmails.map((e) => e.id?.id.value), | ||
equals(['a', 'b', 'c', 'd', 'e']) | ||
); | ||
}); | ||
|
||
test('sortingByOrderOfIdList method should return the original list when the length of the two lists is different', () { | ||
List<Id> ids = [ | ||
Id('a'), | ||
Id('b'), | ||
Id('c'), | ||
]; | ||
List<Email> emails = [ | ||
Email(id: EmailId(Id('a'))), | ||
Email(id: EmailId(Id('c'))), | ||
Email(id: EmailId(Id('e'))), | ||
Email(id: EmailId(Id('d'))), | ||
Email(id: EmailId(Id('b'))) | ||
]; | ||
|
||
List<Email> sortedEmails = emails.sortingByOrderOfIdList(ids); | ||
|
||
expect( | ||
sortedEmails.map((e) => e.id?.id.value), | ||
equals(['a', 'c', 'e', 'd', 'b']) | ||
); | ||
}); | ||
}); | ||
} |