From bd22cd25df14c7555238ef655af59e31c7dcb9ac Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 4 Aug 2023 16:08:16 -0700 Subject: [PATCH] msglist test [nfc]: Reorder to set up listener next to message list itself --- test/model/message_list_test.dart | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/model/message_list_test.dart b/test/model/message_list_test.dart index 22c2ce7ed9..59ac83a9d6 100644 --- a/test/model/message_list_test.dart +++ b/test/model/message_list_test.dart @@ -64,11 +64,7 @@ void main() async { group('maybeUpdateMessage', () { test('update a message', () async { final originalMessage = eg.streamMessage(id: 243, stream: stream, - content: "

Hello, world

", - flags: [], - ); - final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); - + content: "

Hello, world

"); final updateEvent = UpdateMessageEvent( id: 1, messageId: originalMessage.id, @@ -81,6 +77,10 @@ void main() async { renderingOnly: false, ); + final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); + bool listenersNotified = false; + messageList.addListener(() { listenersNotified = true; }); + final message = messageList.messages.single; check(message) ..content.not(it()..equals(updateEvent.renderedContent!)) @@ -88,9 +88,6 @@ void main() async { ..flags.not(it()..deepEquals(updateEvent.flags)) ..isMeMessage.not(it()..equals(updateEvent.isMeMessage!)); - bool listenersNotified = false; - messageList.addListener(() { listenersNotified = true; }); - messageList.maybeUpdateMessage(updateEvent); check(listenersNotified).isTrue(); check(messageList.messages.single) @@ -104,8 +101,6 @@ void main() async { test('ignore when message not present', () async { final originalMessage = eg.streamMessage(id: 243, stream: stream, content: "

Hello, world

"); - final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); - final updateEvent = UpdateMessageEvent( id: 1, messageId: originalMessage.id + 1, @@ -117,6 +112,7 @@ void main() async { renderingOnly: false, ); + final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); bool listenersNotified = false; messageList.addListener(() { listenersNotified = true; }); @@ -132,8 +128,6 @@ void main() async { final originalMessage = eg.streamMessage(id: 972, stream: stream, lastEditTimestamp: 78492, content: "

Hello, world

"); - final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); - final updateEvent = UpdateMessageEvent( id: 1, messageId: originalMessage.id, @@ -145,6 +139,8 @@ void main() async { userId: null, ); + final messageList = await messageListViewWithMessages([originalMessage], stream, narrow); + final message = messageList.messages.single; messageList.maybeUpdateMessage(updateEvent); check(messageList.messages.single)