@@ -813,11 +813,15 @@ void main() {
813
813
return results;
814
814
}
815
815
816
- Iterable <int > getUsersFromResults (Iterable <MentionAutocompleteResult > results)
817
- => results.map ((e) => (e as UserMentionAutocompleteResult ).userId);
816
+ Condition <Object ?> isUser (int userId) {
817
+ return (it) => it.isA <UserMentionAutocompleteResult >()
818
+ .userId.equals (userId);
819
+ }
818
820
819
- Iterable <WildcardMentionOption > getWildcardOptionsFromResults (Iterable <MentionAutocompleteResult > results)
820
- => results.map ((e) => (e as WildcardMentionAutocompleteResult ).wildcardOption);
821
+ Condition <Object ?> isWildcard (WildcardMentionOption option) {
822
+ return (it) => it.isA <WildcardMentionAutocompleteResult >()
823
+ .wildcardOption.equals (option);
824
+ }
821
825
822
826
final stream = eg.stream ();
823
827
const topic = 'topic' ;
@@ -848,20 +852,21 @@ void main() {
848
852
// 3. Users most recent in the DM conversations.
849
853
// 4. Human vs. Bot users (human users come first).
850
854
// 5. Users by name alphabetical order.
851
- final results1 = await getResults (topicNarrow, MentionAutocompleteQuery ('' ));
852
- check ( getWildcardOptionsFromResults (results1. take ( 2 )))
853
- . deepEquals ([ WildcardMentionOption .all, WildcardMentionOption . topic]);
854
- check ( getUsersFromResults (results1. skip ( 2 )))
855
- . deepEquals ([ 1 , 5 , 4 , 2 , 7 , 3 , 6 ]);
855
+ check ( await getResults (topicNarrow, MentionAutocompleteQuery ('' ))). deepEquals ([
856
+ isWildcard ( WildcardMentionOption .all),
857
+ isWildcard ( WildcardMentionOption .topic),
858
+ ...[ 1 , 5 , 4 , 2 , 7 , 3 , 6 ]. map (isUser),
859
+ ]);
856
860
857
861
// Check the ranking applies also to results filtered by a query.
858
- final results2 = await getResults (topicNarrow, MentionAutocompleteQuery ('t' ));
859
- check (getWildcardOptionsFromResults (results2.take (2 )))
860
- .deepEquals ([WildcardMentionOption .stream, WildcardMentionOption .topic]);
861
- check (getUsersFromResults (results2.skip (2 ))).deepEquals ([2 , 3 ]);
862
- final results3 = await getResults (topicNarrow, MentionAutocompleteQuery ('f' ));
863
- check (getWildcardOptionsFromResults (results3.take (0 ))).deepEquals ([]);
864
- check (getUsersFromResults (results3.skip (0 ))).deepEquals ([5 , 4 ]);
862
+ check (await getResults (topicNarrow, MentionAutocompleteQuery ('t' ))).deepEquals ([
863
+ isWildcard (WildcardMentionOption .stream),
864
+ isWildcard (WildcardMentionOption .topic),
865
+ isUser (2 ), isUser (3 ),
866
+ ]);
867
+ check (await getResults (topicNarrow, MentionAutocompleteQuery ('f' ))).deepEquals ([
868
+ isUser (5 ), isUser (4 ),
869
+ ]);
865
870
});
866
871
});
867
872
0 commit comments