Skip to content

Commit 1ffe2b8

Browse files
committed
autocomplete test [nfc]: Remove checkTopicShown helper
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 9bcaf0b commit 1ffe2b8

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

test/widgets/autocomplete_test.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,11 @@ void main() {
392392
});
393393

394394
group('TopicAutocomplete', () {
395-
void checkTopicShown(String topic, PerAccountStore store, {required bool expected}) {
396-
check(find.text(topic).evaluate().length).equals(expected ? 1 : 0);
397-
}
398-
399395
testWidgets('options appear, disappear, and change correctly', (WidgetTester tester) async {
400396
final topic1 = eg.getStreamTopicsEntry(maxId: 1, name: 'Topic one');
401397
final topic2 = eg.getStreamTopicsEntry(maxId: 2, name: 'Topic two');
402398
final topic3 = eg.getStreamTopicsEntry(maxId: 3, name: 'Topic three');
403399
final topicInputFinder = await setupToTopicInput(tester, topics: [topic1, topic2, topic3]);
404-
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
405400

406401
// Options are filtered correctly for query
407402
// TODO(#226): Remove this extra edit when this bug is fixed.
@@ -410,24 +405,24 @@ void main() {
410405
await tester.pumpAndSettle();
411406

412407
// "topic three" and "topic two" appear, but not "topic one"
413-
checkTopicShown('Topic one', store, expected: false);
414-
checkTopicShown('Topic two', store, expected: true);
415-
checkTopicShown('Topic three', store, expected: true);
408+
check(find.text('Topic one' )).findsNothing();
409+
check(find.text('Topic two' )).findsOne();
410+
check(find.text('Topic three')).findsOne();
416411

417412
// Finishing autocomplete updates topic box; causes options to disappear
418413
await tester.tap(find.text('Topic three'));
419414
await tester.pumpAndSettle();
420415
check(tester.widget<TextField>(topicInputFinder).controller!.text)
421416
.equals(topic3.name.displayName);
422-
checkTopicShown('Topic one', store, expected: false);
423-
checkTopicShown('Topic two', store, expected: false);
424-
checkTopicShown('Topic three', store, expected: true); // shown in `_TopicInput` once
417+
check(find.text('Topic one' )).findsNothing();
418+
check(find.text('Topic two' )).findsNothing();
419+
check(find.text('Topic three')).findsOne(); // shown in `_TopicInput` once
425420

426421
// Then a new autocomplete intent brings up options again
427422
await tester.enterText(topicInputFinder, 'Topic');
428423
await tester.enterText(topicInputFinder, 'Topic T');
429424
await tester.pumpAndSettle();
430-
checkTopicShown('Topic two', store, expected: true);
425+
check(find.text('Topic two')).findsOne();
431426
});
432427

433428
testWidgets('text selection is reset on choosing an option', (tester) async {

0 commit comments

Comments
 (0)