Skip to content

Commit

Permalink
msglist test [nfc]: Reorder to set up listener next to message list i…
Browse files Browse the repository at this point in the history
…tself
  • Loading branch information
gnprice committed Aug 4, 2023
1 parent f661e66 commit bd22cd2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/model/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ void main() async {
group('maybeUpdateMessage', () {
test('update a message', () async {
final originalMessage = eg.streamMessage(id: 243, stream: stream,
content: "<p>Hello, world</p>",
flags: [],
);
final messageList = await messageListViewWithMessages([originalMessage], stream, narrow);

content: "<p>Hello, world</p>");
final updateEvent = UpdateMessageEvent(
id: 1,
messageId: originalMessage.id,
Expand All @@ -81,16 +77,17 @@ 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!))
..lastEditTimestamp.isNull()
..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)
Expand All @@ -104,8 +101,6 @@ void main() async {
test('ignore when message not present', () async {
final originalMessage = eg.streamMessage(id: 243, stream: stream,
content: "<p>Hello, world</p>");
final messageList = await messageListViewWithMessages([originalMessage], stream, narrow);

final updateEvent = UpdateMessageEvent(
id: 1,
messageId: originalMessage.id + 1,
Expand All @@ -117,6 +112,7 @@ void main() async {
renderingOnly: false,
);

final messageList = await messageListViewWithMessages([originalMessage], stream, narrow);
bool listenersNotified = false;
messageList.addListener(() { listenersNotified = true; });

Expand All @@ -132,8 +128,6 @@ void main() async {
final originalMessage = eg.streamMessage(id: 972, stream: stream,
lastEditTimestamp: 78492,
content: "<p>Hello, world</p>");
final messageList = await messageListViewWithMessages([originalMessage], stream, narrow);

final updateEvent = UpdateMessageEvent(
id: 1,
messageId: originalMessage.id,
Expand All @@ -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)
Expand Down

0 comments on commit bd22cd2

Please sign in to comment.