Skip to content

Commit dbf86dd

Browse files
committed
msglist test: Use a realistic GetMessagesResult for fetch
1 parent 9a07d7d commit dbf86dd

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

test/model/message_list_test.dart

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@ Future<MessageListView> messageListViewWithMessages(List<Message> messages, [Nar
1717
final model = MessageListView.init(store: store, narrow: narrow);
1818

1919
final connection = store.connection as FakeApiConnection;
20-
connection.prepare(json: GetMessagesResult(
21-
anchor: messages.first.id,
22-
foundNewest: true,
23-
foundOldest: true,
24-
foundAnchor: true,
25-
historyLimited: false,
26-
messages: messages,
27-
).toJson());
20+
connection.prepare(json:
21+
newestResult(foundOldest: true, messages: messages).toJson());
2822
await model.fetch();
2923

3024
return model;
@@ -257,3 +251,22 @@ extension MessageListViewChecks on Subject<MessageListView> {
257251
Subject<List<ZulipContent>> get contents => has((x) => x.contents, 'contents');
258252
Subject<bool> get fetched => has((x) => x.fetched, 'fetched');
259253
}
254+
255+
/// A GetMessagesResult the server might return on an `anchor=newest` request.
256+
GetMessagesResult newestResult({
257+
required bool foundOldest,
258+
bool historyLimited = false,
259+
required List<Message> messages,
260+
}) {
261+
return GetMessagesResult(
262+
// These anchor, foundAnchor, and foundNewest values are what the server
263+
// appears to always return when the request had `anchor=newest`.
264+
anchor: 10000000000000000, // that's 16 zeros
265+
foundAnchor: false,
266+
foundNewest: true,
267+
268+
foundOldest: foundOldest,
269+
historyLimited: historyLimited,
270+
messages: messages,
271+
);
272+
}

0 commit comments

Comments
 (0)