Skip to content

Commit 2b8d848

Browse files
committed
autocomplete test: Separate getting results from checking in end-to-end test
This is nearly NFC, but also adds a `dispose` call to tidy things up after getting the results.
1 parent 739fa84 commit 2b8d848

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/model/autocomplete_test.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,22 +614,24 @@ void main() {
614614
await messageList.fetchInitial();
615615
}
616616

617-
Future<void> checkResultsIn(Narrow narrow, {required List<int> expected}) async {
618-
final view = MentionAutocompleteView.init(store: store, narrow: narrow);
619-
617+
Future<Iterable<int>> getResults(
618+
Narrow narrow, MentionAutocompleteQuery query) async {
620619
bool done = false;
620+
final view = MentionAutocompleteView.init(store: store, narrow: narrow);
621621
view.addListener(() { done = true; });
622-
view.query = MentionAutocompleteQuery('');
622+
view.query = query;
623623
await Future(() {});
624624
check(done).isTrue();
625625
final results = view.results
626626
.map((e) => (e as UserMentionAutocompleteResult).userId);
627-
check(results).deepEquals(expected);
627+
view.dispose();
628+
return results;
628629
}
629630

630631
await prepareStore();
631632
await fetchInitialMessagesIn(topicNarrow);
632-
await checkResultsIn(topicNarrow, expected: [1, 5, 4, 2, 3]);
633+
check(await getResults(topicNarrow, MentionAutocompleteQuery('')))
634+
.deepEquals([1, 5, 4, 2, 3]);
633635
});
634636
});
635637
}

0 commit comments

Comments
 (0)