2
2
import 'package:checks/checks.dart' ;
3
3
import 'package:test/scaffolding.dart' ;
4
4
import 'package:zulip/api/model/model.dart' ;
5
- import 'package:zulip/model/message.dart' ;
6
5
import 'package:zulip/model/narrow.dart' ;
7
6
8
7
import '../example_data.dart' as eg;
9
8
import 'narrow_checks.dart' ;
10
9
11
10
void main () {
12
- int nextLocalMessageId = 1 ;
13
-
14
- StreamOutboxMessage streamOutboxMessage ({
15
- required ZulipStream stream,
16
- required String topic,
17
- }) {
18
- return OutboxMessage .fromConversation (
19
- StreamConversation (
20
- stream.streamId, TopicName (topic), displayRecipient: null ),
21
- localMessageId: nextLocalMessageId++ ,
22
- selfUserId: eg.selfUser.userId,
23
- timestamp: 123456789 ,
24
- contentMarkdown: 'content' ) as StreamOutboxMessage ;
25
- }
26
-
27
- DmOutboxMessage dmOutboxMessage ({required List <int > allRecipientIds}) {
28
- final senderUserId = allRecipientIds[0 ];
29
- return OutboxMessage .fromConversation (
30
- DmConversation (allRecipientIds: allRecipientIds..sort ()),
31
- localMessageId: nextLocalMessageId++ ,
32
- selfUserId: senderUserId,
33
- timestamp: 123456789 ,
34
- contentMarkdown: 'content' ) as DmOutboxMessage ;
35
- }
36
-
37
11
group ('SendableNarrow' , () {
38
12
test ('ofMessage: stream message' , () {
39
13
final message = eg.streamMessage ();
@@ -61,11 +35,11 @@ void main() {
61
35
eg.streamMessage (stream: stream, topic: 'topic' ))).isTrue ();
62
36
63
37
check (narrow.containsMessage (
64
- dmOutboxMessage (allRecipientIds : [ 1 ]))).isFalse ();
38
+ eg. dmOutboxMessage (from : eg.selfUser, to : [eg.otherUser ]))).isFalse ();
65
39
check (narrow.containsMessage (
66
- streamOutboxMessage (stream: otherStream, topic: 'topic' ))).isFalse ();
40
+ eg. streamOutboxMessage (stream: otherStream, topic: 'topic' ))).isFalse ();
67
41
check (narrow.containsMessage (
68
- streamOutboxMessage (stream: stream, topic: 'topic' ))).isTrue ();
42
+ eg. streamOutboxMessage (stream: stream, topic: 'topic' ))).isTrue ();
69
43
});
70
44
});
71
45
@@ -91,13 +65,13 @@ void main() {
91
65
eg.streamMessage (stream: stream, topic: 'topic' ))).isTrue ();
92
66
93
67
check (narrow.containsMessage (
94
- dmOutboxMessage (allRecipientIds : [ 1 ]))).isFalse ();
68
+ eg. dmOutboxMessage (from : eg.selfUser, to : [eg.otherUser ]))).isFalse ();
95
69
check (narrow.containsMessage (
96
- streamOutboxMessage (stream: otherStream, topic: 'topic' ))).isFalse ();
70
+ eg. streamOutboxMessage (stream: otherStream, topic: 'topic' ))).isFalse ();
97
71
check (narrow.containsMessage (
98
- streamOutboxMessage (stream: stream, topic: 'topic2' ))).isFalse ();
72
+ eg. streamOutboxMessage (stream: stream, topic: 'topic2' ))).isFalse ();
99
73
check (narrow.containsMessage (
100
- streamOutboxMessage (stream: stream, topic: 'topic' ))).isTrue ();
74
+ eg. streamOutboxMessage (stream: stream, topic: 'topic' ))).isTrue ();
101
75
});
102
76
});
103
77
@@ -220,16 +194,19 @@ void main() {
220
194
});
221
195
222
196
test ('containsMessage with non-Message' , () {
197
+ final user1 = eg.user (userId: 1 );
198
+ final user2 = eg.user (userId: 2 );
199
+ final user3 = eg.user (userId: 3 );
223
200
final narrow = DmNarrow (allRecipientIds: [1 , 2 ], selfUserId: 2 );
224
201
225
202
check (narrow.containsMessage (
226
- streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
203
+ eg. streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
227
204
check (narrow.containsMessage (
228
- dmOutboxMessage (allRecipientIds : [ 2 ]))).isFalse ();
205
+ eg. dmOutboxMessage (from : user2, to : [ ]))).isFalse ();
229
206
check (narrow.containsMessage (
230
- dmOutboxMessage (allRecipientIds : [ 2 , 3 ]))).isFalse ();
207
+ eg. dmOutboxMessage (from : user2, to : [user3 ]))).isFalse ();
231
208
check (narrow.containsMessage (
232
- dmOutboxMessage (allRecipientIds : [ 2 , 1 ]))).isTrue ();
209
+ eg. dmOutboxMessage (from : user2, to : [user1 ]))).isTrue ();
233
210
});
234
211
});
235
212
@@ -245,9 +222,9 @@ void main() {
245
222
eg.streamMessage (flags: [MessageFlag .wildcardMentioned]))).isTrue ();
246
223
247
224
check (narrow.containsMessage (
248
- streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
225
+ eg. streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
249
226
check (narrow.containsMessage (
250
- dmOutboxMessage (allRecipientIds : [ eg.selfUser.userId ]))).isFalse ();
227
+ eg. dmOutboxMessage (from : eg.selfUser, to : [ ]))).isFalse ();
251
228
});
252
229
});
253
230
@@ -261,9 +238,9 @@ void main() {
261
238
eg.streamMessage (flags: [MessageFlag .starred]))).isTrue ();
262
239
263
240
check (narrow.containsMessage (
264
- streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
241
+ eg. streamOutboxMessage (stream: eg.stream (), topic: 'topic' ))).isFalse ();
265
242
check (narrow.containsMessage (
266
- dmOutboxMessage (allRecipientIds : [ eg.selfUser.userId ]))).isFalse ();
243
+ eg. dmOutboxMessage (from : eg.selfUser, to : [ ]))).isFalse ();
267
244
});
268
245
});
269
246
}
0 commit comments