Skip to content

Commit fbee491

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): #1327 (comment)
1 parent 3321ad4 commit fbee491

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
@@ -375,26 +375,26 @@ void main() {
375375
group('RealmUserUpdateEvent', () {
376376
// TODO write more tests for handling RealmUserUpdateEvent
377377

378-
test('deliveryEmail', () {
378+
test('deliveryEmail', () async {
379379
final user = eg.user(deliveryEmail: '[email protected]');
380380
final store = eg.store(initialSnapshot: eg.initialSnapshot(
381381
realmUsers: [eg.selfUser, user]));
382382

383383
User getUser() => store.users[user.userId]!;
384384

385-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
385+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
386386
deliveryEmail: null));
387387
check(getUser()).deliveryEmail.equals('[email protected]');
388388

389-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
389+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
390390
deliveryEmail: const JsonNullable(null)));
391391
check(getUser()).deliveryEmail.isNull();
392392

393-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
393+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
394394
deliveryEmail: const JsonNullable('[email protected]')));
395395
check(getUser()).deliveryEmail.equals('[email protected]');
396396

397-
store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
397+
await store.handleEvent(RealmUserUpdateEvent(id: 1, userId: user.userId,
398398
deliveryEmail: const JsonNullable('[email protected]')));
399399
check(getUser()).deliveryEmail.equals('[email protected]');
400400
});

test/widgets/message_list_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ void main() {
799799
foundOldest: false, messages: messages).toJson());
800800
}
801801

802-
void handleMessageMoveEvent(List<StreamMessage> messages, String newTopic, {int? newChannelId}) {
803-
store.handleEvent(eg.updateMessageEventMoveFrom(
802+
Future<void> handleMessageMoveEvent(List<StreamMessage> messages, String newTopic, {int? newChannelId}) async {
803+
await store.handleEvent(eg.updateMessageEventMoveFrom(
804804
origMessages: messages,
805805
newTopicStr: newTopic,
806806
newStreamId: newChannelId,
@@ -821,7 +821,7 @@ void main() {
821821
..controller.isNotNull().text.equals('Some text');
822822

823823
prepareGetMessageResponse([message]);
824-
handleMessageMoveEvent([message], 'new topic', newChannelId: otherChannel.streamId);
824+
await handleMessageMoveEvent([message], 'new topic', newChannelId: otherChannel.streamId);
825825
await tester.pump(const Duration(seconds: 1));
826826
check(tester.widget<TextField>(channelContentInputFinder))
827827
..decoration.isNotNull().hintText.equals('Message #${otherChannel.name} > new topic')
@@ -851,7 +851,7 @@ void main() {
851851
final existingMessage = eg.streamMessage(
852852
stream: eg.stream(), topic: 'new topic', content: 'Existing message');
853853
prepareGetMessageResponse([existingMessage, message]);
854-
handleMessageMoveEvent([message], 'new topic');
854+
await handleMessageMoveEvent([message], 'new topic');
855855
await tester.pump(const Duration(seconds: 1));
856856

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

865865
prepareGetMessageResponse([message]);
866-
handleMessageMoveEvent([message], 'new topic');
866+
await handleMessageMoveEvent([message], 'new topic');
867867
await tester.pump(const Duration(seconds: 1));
868868

869869
check(find.descendant(

0 commit comments

Comments
 (0)