Skip to content

Commit

Permalink
TF-2528 Add unit test for sortingListEmailByOrderIdList method
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 authored and hoangdat committed Nov 14, 2024
1 parent e6ae472 commit cf2a0b0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/features/email/sorting_list_email_by_order_id_list_test.dart
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'])
);
});
});
}

0 comments on commit cf2a0b0

Please sign in to comment.