Skip to content

Commit a1dc2a0

Browse files
committed
test [nfc]: Add the few missing awaits on handleEvent calls
This is NFC because there isn't currently actually anything to wait for; the implementation of handleEvent is entirely synchronous. But in principle it's async, because in the future it will be, for the reasons described in baea6d7. Thanks to Zixuan for spotting this pattern in some newly-added tests (coming up): zulip#1327 (comment)
1 parent c66a905 commit a1dc2a0

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

test/model/emoji_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ void main() {
262262
]);
263263
});
264264

265-
test('updates on RealmEmojiUpdateEvent', () {
265+
test('updates on RealmEmojiUpdateEvent', () async {
266266
final store = prepare();
267267
check(store.allEmojiCandidates()).deepEquals([
268268
...arePopularCandidates,
269269
isZulipCandidate(),
270270
]);
271271

272-
store.handleEvent(RealmEmojiUpdateEvent(id: 1, realmEmoji: {
272+
await store.handleEvent(RealmEmojiUpdateEvent(id: 1, realmEmoji: {
273273
'1': eg.realmEmojiItem(emojiCode: '1', emojiName: 'happy'),
274274
}));
275275
check(store.allEmojiCandidates()).deepEquals([

test/model/store_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,26 +353,26 @@ void main() {
353353
group('RealmUserUpdateEvent', () {
354354
// TODO write more tests for handling RealmUserUpdateEvent
355355

356-
test('deliveryEmail', () {
356+
test('deliveryEmail', () async {
357357
final user = eg.user(deliveryEmail: '[email protected]');
358358
final store = eg.store(initialSnapshot: eg.initialSnapshot(
359359
realmUsers: [eg.selfUser, user]));
360360

361361
User getUser() => store.users[user.userId]!;
362362

363-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
363+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
364364
deliveryEmail: null));
365365
check(getUser()).deliveryEmail.equals('[email protected]');
366366

367-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
367+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
368368
deliveryEmail: const JsonNullable(null)));
369369
check(getUser()).deliveryEmail.isNull();
370370

371-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
371+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
372372
deliveryEmail: const JsonNullable('[email protected]')));
373373
check(getUser()).deliveryEmail.equals('[email protected]');
374374

375-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
375+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
376376
deliveryEmail: const JsonNullable('[email protected]')));
377377
check(getUser()).deliveryEmail.equals('[email protected]');
378378
});

test/widgets/message_list_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,8 @@ void main() {
670670
foundOldest: false, messages: messages).toJson());
671671
}
672672

673-
void handleMessageMoveEvent(List<StreamMessage> messages, String newTopic, {int? newChannelId}) {
674-
store.handleEvent(eg.updateMessageEventMoveFrom(
673+
Future<void> handleMessageMoveEvent(List<StreamMessage> messages, String newTopic, {int? newChannelId}) async {
674+
await store.handleEvent(eg.updateMessageEventMoveFrom(
675675
origMessages: messages,
676676
newTopicStr: newTopic,
677677
newStreamId: newChannelId,
@@ -692,7 +692,7 @@ void main() {
692692
..controller.isNotNull().text.equals('Some text');
693693

694694
prepareGetMessageResponse([message]);
695-
handleMessageMoveEvent([message], 'new topic', newChannelId: otherChannel.streamId);
695+
await handleMessageMoveEvent([message], 'new topic', newChannelId: otherChannel.streamId);
696696
await tester.pump(const Duration(seconds: 1));
697697
check(tester.widget<TextField>(channelContentInputFinder))
698698
..decoration.isNotNull().hintText.equals('Message #${otherChannel.name} > new topic')
@@ -722,7 +722,7 @@ void main() {
722722
final existingMessage = eg.streamMessage(
723723
stream: eg.stream(), topic: 'new topic', content: 'Existing message');
724724
prepareGetMessageResponse([existingMessage, message]);
725-
handleMessageMoveEvent([message], 'new topic');
725+
await handleMessageMoveEvent([message], 'new topic');
726726
await tester.pump(const Duration(seconds: 1));
727727

728728
check(find.textContaining('Existing message').evaluate()).length.equals(1);
@@ -734,7 +734,7 @@ void main() {
734734
await setupMessageListPage(tester, narrow: narrow, messages: [message], streams: [channel]);
735735

736736
prepareGetMessageResponse([message]);
737-
handleMessageMoveEvent([message], 'new topic');
737+
await handleMessageMoveEvent([message], 'new topic');
738738
await tester.pump(const Duration(seconds: 1));
739739

740740
check(find.descendant(

0 commit comments

Comments
 (0)