@@ -20,10 +20,12 @@ void main() {
20
20
required bool expectLegacy,
21
21
required int messageId,
22
22
bool ? applyMarkdown,
23
+ required bool allowEmptyTopicName,
23
24
}) async {
24
25
final result = await getMessageCompat (connection,
25
26
messageId: messageId,
26
27
applyMarkdown: applyMarkdown,
28
+ allowEmptyTopicName: allowEmptyTopicName,
27
29
);
28
30
if (expectLegacy) {
29
31
check (connection.lastRequest).isA< http.Request > ()
@@ -35,6 +37,7 @@ void main() {
35
37
'num_before' : '0' ,
36
38
'num_after' : '0' ,
37
39
if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
40
+ 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
38
41
'client_gravatar' : 'true' ,
39
42
});
40
43
} else {
@@ -43,6 +46,7 @@ void main() {
43
46
..url.path.equals ('/api/v1/messages/$messageId ' )
44
47
..url.queryParameters.deepEquals ({
45
48
if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
49
+ 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
46
50
});
47
51
}
48
52
return result;
@@ -57,6 +61,7 @@ void main() {
57
61
expectLegacy: false ,
58
62
messageId: message.id,
59
63
applyMarkdown: true ,
64
+ allowEmptyTopicName: true ,
60
65
);
61
66
check (result).isNotNull ().jsonEquals (message);
62
67
});
@@ -71,6 +76,7 @@ void main() {
71
76
expectLegacy: false ,
72
77
messageId: message.id,
73
78
applyMarkdown: true ,
79
+ allowEmptyTopicName: true ,
74
80
);
75
81
check (result).isNull ();
76
82
});
@@ -92,6 +98,7 @@ void main() {
92
98
expectLegacy: true ,
93
99
messageId: message.id,
94
100
applyMarkdown: true ,
101
+ allowEmptyTopicName: true ,
95
102
);
96
103
check (result).isNotNull ().jsonEquals (message);
97
104
});
@@ -113,6 +120,7 @@ void main() {
113
120
expectLegacy: true ,
114
121
messageId: message.id,
115
122
applyMarkdown: true ,
123
+ allowEmptyTopicName: true ,
116
124
);
117
125
check (result).isNull ();
118
126
});
@@ -124,11 +132,13 @@ void main() {
124
132
FakeApiConnection connection, {
125
133
required int messageId,
126
134
bool ? applyMarkdown,
135
+ required bool allowEmptyTopicName,
127
136
required Map <String , String > expected,
128
137
}) async {
129
138
final result = await getMessage (connection,
130
139
messageId: messageId,
131
140
applyMarkdown: applyMarkdown,
141
+ allowEmptyTopicName: allowEmptyTopicName,
132
142
);
133
143
check (connection.lastRequest).isA< http.Request > ()
134
144
..method.equals ('GET' )
@@ -145,7 +155,11 @@ void main() {
145
155
await checkGetMessage (connection,
146
156
messageId: 1 ,
147
157
applyMarkdown: true ,
148
- expected: {'apply_markdown' : 'true' });
158
+ allowEmptyTopicName: true ,
159
+ expected: {
160
+ 'apply_markdown' : 'true' ,
161
+ 'allow_empty_topic_name' : 'true' ,
162
+ });
149
163
});
150
164
});
151
165
@@ -155,7 +169,21 @@ void main() {
155
169
await checkGetMessage (connection,
156
170
messageId: 1 ,
157
171
applyMarkdown: false ,
158
- expected: {'apply_markdown' : 'false' });
172
+ allowEmptyTopicName: true ,
173
+ expected: {
174
+ 'apply_markdown' : 'false' ,
175
+ 'allow_empty_topic_name' : 'true' ,
176
+ });
177
+ });
178
+ });
179
+
180
+ test ('allow empty topic name' , () {
181
+ return FakeApiConnection .with_ ((connection) async {
182
+ connection.prepare (json: fakeResult.toJson ());
183
+ await checkGetMessage (connection,
184
+ messageId: 1 ,
185
+ allowEmptyTopicName: true ,
186
+ expected: {'allow_empty_topic_name' : 'true' });
159
187
});
160
188
});
161
189
@@ -164,6 +192,7 @@ void main() {
164
192
connection.prepare (json: fakeResult.toJson ());
165
193
check (() => getMessage (connection,
166
194
messageId: 1 ,
195
+ allowEmptyTopicName: true ,
167
196
)).throws <AssertionError >();
168
197
});
169
198
});
@@ -255,12 +284,14 @@ void main() {
255
284
required int numAfter,
256
285
bool ? clientGravatar,
257
286
bool ? applyMarkdown,
287
+ required bool allowEmptyTopicName,
258
288
required Map <String , String > expected,
259
289
}) async {
260
290
final result = await getMessages (connection,
261
291
narrow: narrow, anchor: anchor, includeAnchor: includeAnchor,
262
292
numBefore: numBefore, numAfter: numAfter,
263
293
clientGravatar: clientGravatar, applyMarkdown: applyMarkdown,
294
+ allowEmptyTopicName: allowEmptyTopicName,
264
295
);
265
296
check (connection.lastRequest).isA< http.Request > ()
266
297
..method.equals ('GET' )
@@ -279,11 +310,13 @@ void main() {
279
310
await checkGetMessages (connection,
280
311
narrow: const CombinedFeedNarrow ().apiEncode (),
281
312
anchor: AnchorCode .newest, numBefore: 10 , numAfter: 20 ,
313
+ allowEmptyTopicName: true ,
282
314
expected: {
283
315
'narrow' : jsonEncode ([]),
284
316
'anchor' : 'newest' ,
285
317
'num_before' : '10' ,
286
318
'num_after' : '20' ,
319
+ 'allow_empty_topic_name' : 'true' ,
287
320
});
288
321
});
289
322
});
@@ -294,13 +327,15 @@ void main() {
294
327
await checkGetMessages (connection,
295
328
narrow: [ApiNarrowDm ([123 , 234 ])],
296
329
anchor: AnchorCode .newest, numBefore: 10 , numAfter: 20 ,
330
+ allowEmptyTopicName: true ,
297
331
expected: {
298
332
'narrow' : jsonEncode ([
299
333
{'operator' : 'pm-with' , 'operand' : [123 , 234 ]},
300
334
]),
301
335
'anchor' : 'newest' ,
302
336
'num_before' : '10' ,
303
337
'num_after' : '20' ,
338
+ 'allow_empty_topic_name' : 'true' ,
304
339
});
305
340
});
306
341
});
@@ -312,11 +347,13 @@ void main() {
312
347
narrow: const CombinedFeedNarrow ().apiEncode (),
313
348
anchor: const NumericAnchor (42 ),
314
349
numBefore: 10 , numAfter: 20 ,
350
+ allowEmptyTopicName: true ,
315
351
expected: {
316
352
'narrow' : jsonEncode ([]),
317
353
'anchor' : '42' ,
318
354
'num_before' : '10' ,
319
355
'num_after' : '20' ,
356
+ 'allow_empty_topic_name' : 'true' ,
320
357
});
321
358
});
322
359
});
0 commit comments