Skip to content

Commit 1e781dd

Browse files
committed
autocomplete test [nfc]: Do constant-folding in end-to-end test
Now that many of these helpers have just one call site, they can be simplified.
1 parent a14ea8b commit 1e781dd

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

test/model/autocomplete_test.dart

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,19 @@ void main() {
599599
streamMessage(id: 60, senderId: 4),
600600
];
601601

602-
Future<void> prepareStore({bool includeMessageHistory = false}) async {
602+
Future<void> prepareStore() async {
603603
await prepare(users: users, dmConversations: dmConversations,
604-
messages: includeMessageHistory ? messages : []);
604+
messages: messages);
605+
}
606+
607+
Future<void> fetchInitialMessagesIn(Narrow narrow) async {
608+
final connection = store.connection as FakeApiConnection;
609+
connection.prepare(json: newestResult(
610+
foundOldest: false,
611+
messages: messages.where((m) => m.topic == topic).toList(),
612+
).toJson());
613+
final messageList = MessageListView.init(store: store, narrow: narrow);
614+
await messageList.fetchInitial();
605615
}
606616

607617
Future<void> checkResultsIn(Narrow narrow, {required List<int> expected}) async {
@@ -617,31 +627,9 @@ void main() {
617627
check(results).deepEquals(expected);
618628
}
619629

620-
late FakeApiConnection connection;
621-
late MessageListView messageList;
622-
623-
Future<void> fetchInitialMessagesIn(Narrow narrow) async {
624-
connection = store.connection as FakeApiConnection;
625-
connection.prepare(json: newestResult(
626-
foundOldest: false,
627-
messages: narrow is StreamNarrow
628-
? messages
629-
: messages.where((m) => m.topic == topic).toList(),
630-
).toJson());
631-
messageList = MessageListView.init(store: store, narrow: narrow);
632-
await messageList.fetchInitial();
633-
}
634-
635-
Future<void> checkInitialResultsIn(Narrow narrow,
636-
{required List<int> expected, bool includeStream = false}) async {
637-
assert(narrow is! StreamNarrow || !includeStream);
638-
await prepareStore(includeMessageHistory: includeStream);
639-
await fetchInitialMessagesIn(narrow);
640-
await checkResultsIn(narrow, expected: expected);
641-
}
642-
643-
await checkInitialResultsIn(topicNarrow, expected: [0, 4, 3, 1, 2],
644-
includeStream: true);
630+
await prepareStore();
631+
await fetchInitialMessagesIn(topicNarrow);
632+
await checkResultsIn(topicNarrow, expected: [0, 4, 3, 1, 2]);
645633
});
646634
});
647635
}

0 commit comments

Comments
 (0)