Skip to content

Commit e4528fd

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

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
@@ -334,16 +334,11 @@ void main() {
334334
});
335335

336336
group('TopicAutocomplete', () {
337-
void checkTopicShown(String topic, PerAccountStore store, {required bool expected}) {
338-
check(find.text(topic).evaluate().length).equals(expected ? 1 : 0);
339-
}
340-
341337
testWidgets('options appear, disappear, and change correctly', (WidgetTester tester) async {
342338
final topic1 = eg.getStreamTopicsEntry(maxId: 1, name: 'Topic one');
343339
final topic2 = eg.getStreamTopicsEntry(maxId: 2, name: 'Topic two');
344340
final topic3 = eg.getStreamTopicsEntry(maxId: 3, name: 'Topic three');
345341
final topicInputFinder = await setupToTopicInput(tester, topics: [topic1, topic2, topic3]);
346-
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
347342

348343
// Options are filtered correctly for query
349344
// TODO(#226): Remove this extra edit when this bug is fixed.
@@ -352,24 +347,24 @@ void main() {
352347
await tester.pumpAndSettle();
353348

354349
// "topic three" and "topic two" appear, but not "topic one"
355-
checkTopicShown('Topic one', store, expected: false);
356-
checkTopicShown('Topic two', store, expected: true);
357-
checkTopicShown('Topic three', store, expected: true);
350+
check(find.text('Topic one' )).findsNothing();
351+
check(find.text('Topic two' )).findsOne();
352+
check(find.text('Topic three')).findsOne();
358353

359354
// Finishing autocomplete updates topic box; causes options to disappear
360355
await tester.tap(find.text('Topic three'));
361356
await tester.pumpAndSettle();
362357
check(tester.widget<TextField>(topicInputFinder).controller!.text)
363358
.equals(topic3.name.displayName);
364-
checkTopicShown('Topic one', store, expected: false);
365-
checkTopicShown('Topic two', store, expected: false);
366-
checkTopicShown('Topic three', store, expected: true); // shown in `_TopicInput` once
359+
check(find.text('Topic one' )).findsNothing();
360+
check(find.text('Topic two' )).findsNothing();
361+
check(find.text('Topic three')).findsOne(); // shown in `_TopicInput` once
367362

368363
// Then a new autocomplete intent brings up options again
369364
await tester.enterText(topicInputFinder, 'Topic');
370365
await tester.enterText(topicInputFinder, 'Topic T');
371366
await tester.pumpAndSettle();
372-
checkTopicShown('Topic two', store, expected: true);
367+
check(find.text('Topic two')).findsOne();
373368
});
374369

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

0 commit comments

Comments
 (0)