Skip to content

Commit ae07310

Browse files
committed
test [nfc]: Have eg.streamMessage() take optional ZulipStream and topic
1 parent 136c41e commit ae07310

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/example_data.dart

+5-6
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ Map<String, dynamic> _messagePropertiesFromSender(User? sender) {
103103
};
104104
}
105105

106-
// When we have a Stream object, this can take that as an argument.
107-
// Also it can default explicitly to an example stream.
108106
StreamMessage streamMessage(
109-
{User? sender, String? streamName, int? streamId}) {
107+
{User? sender, ZulipStream? inStream, String? topic}) {
108+
final effectiveStream = inStream ?? stream();
110109
// The use of JSON here is convenient in order to delegate parts of the data
111110
// to helper functions. The main downside is that it loses static typing
112111
// of the properties as we're constructing the data. That's probably OK
@@ -115,14 +114,14 @@ StreamMessage streamMessage(
115114
return StreamMessage.fromJson({
116115
..._messagePropertiesBase,
117116
..._messagePropertiesFromSender(sender),
118-
'display_recipient': streamName ?? 'a stream',
119-
'stream_id': streamId ?? 123, // TODO generate example IDs
117+
'display_recipient': effectiveStream.name,
118+
'stream_id': effectiveStream.streamId,
120119

121120
'content': '<p>This is an example stream message.</p>',
122121
'content_type': 'text/html',
123122
'flags': [],
124123
'id': 1234567, // TODO generate example IDs
125-
'subject': 'example topic',
124+
'subject': topic ?? 'example topic',
126125
'timestamp': 1678139636,
127126
'type': 'stream',
128127
});

0 commit comments

Comments
 (0)