Skip to content

Commit 1b59036

Browse files
committed
msglist test [nfc]: Refactor fetchInitial smoke, preparing for more narrows
1 parent 48da972 commit 1b59036

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

test/model/message_list_test.dart

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,36 @@ void main() {
9696
}
9797

9898
group('fetchInitial', () {
99-
test('smoke', () async {
100-
const narrow = CombinedFeedNarrow();
101-
await prepare(narrow: narrow);
102-
connection.prepare(json: newestResult(
103-
foundOldest: false,
104-
messages: List.generate(kMessageListFetchBatchSize,
105-
(i) => eg.streamMessage()),
106-
).toJson());
107-
final fetchFuture = model.fetchInitial();
108-
check(model).fetched.isFalse();
99+
group('smoke', () {
100+
Future<void> smoke(
101+
Narrow narrow,
102+
Message Function(int i) generateMessages,
103+
) async {
104+
await prepare(narrow: narrow);
105+
connection.prepare(json: newestResult(
106+
foundOldest: false,
107+
messages: List.generate(kMessageListFetchBatchSize, generateMessages),
108+
).toJson());
109+
final fetchFuture = model.fetchInitial();
110+
check(model).fetched.isFalse();
109111

110-
checkNotNotified();
111-
await fetchFuture;
112-
checkNotifiedOnce();
113-
check(model)
114-
..messages.length.equals(kMessageListFetchBatchSize)
115-
..haveOldest.isFalse();
116-
checkLastRequest(
117-
narrow: narrow.apiEncode(),
118-
anchor: 'newest',
119-
numBefore: kMessageListFetchBatchSize,
120-
numAfter: 0,
121-
);
112+
checkNotNotified();
113+
await fetchFuture;
114+
checkNotifiedOnce();
115+
check(model)
116+
..messages.length.equals(kMessageListFetchBatchSize)
117+
..haveOldest.isFalse();
118+
checkLastRequest(
119+
narrow: narrow.apiEncode(),
120+
anchor: 'newest',
121+
numBefore: kMessageListFetchBatchSize,
122+
numAfter: 0,
123+
);
124+
}
125+
126+
test('CombinedFeedNarrow', () async {
127+
await smoke(const CombinedFeedNarrow(), (i) => eg.streamMessage());
128+
});
122129
});
123130

124131
test('short history', () async {

0 commit comments

Comments
 (0)