@@ -13,6 +13,56 @@ import '../fake_api.dart';
13
13
import 'route_checks.dart' ;
14
14
15
15
void main () {
16
+ group ('getMessage' , () {
17
+ Future <GetMessageResult > checkGetMessage (
18
+ FakeApiConnection connection, {
19
+ required int messageId,
20
+ bool ? applyMarkdown,
21
+ required Map <String , String > expected,
22
+ }) async {
23
+ final result = await getMessage (connection,
24
+ messageId: messageId,
25
+ applyMarkdown: applyMarkdown,
26
+ );
27
+ check (connection.lastRequest).isNotNull ().isA< http.Request > ()
28
+ ..method.equals ('GET' )
29
+ ..url.path.equals ('/api/v1/messages/$messageId ' )
30
+ ..url.queryParameters.deepEquals (expected);
31
+ return result;
32
+ }
33
+
34
+ final fakeResult = GetMessageResult (message: eg.streamMessage ());
35
+
36
+ test ('applyMarkdown true' , () {
37
+ return FakeApiConnection .with_ ((connection) async {
38
+ connection.prepare (json: fakeResult.toJson ());
39
+ await checkGetMessage (connection,
40
+ messageId: 1 ,
41
+ applyMarkdown: true ,
42
+ expected: {'apply_markdown' : 'true' });
43
+ });
44
+ });
45
+
46
+ test ('applyMarkdown false' , () {
47
+ return FakeApiConnection .with_ ((connection) async {
48
+ connection.prepare (json: fakeResult.toJson ());
49
+ await checkGetMessage (connection,
50
+ messageId: 1 ,
51
+ applyMarkdown: false ,
52
+ expected: {'apply_markdown' : 'false' });
53
+ });
54
+ });
55
+
56
+ test ('Throws assertion error when FL <120' , () {
57
+ return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
58
+ connection.prepare (json: fakeResult.toJson ());
59
+ check (() => getMessage (connection,
60
+ messageId: 1 ,
61
+ )).throws <AssertionError >();
62
+ });
63
+ });
64
+ });
65
+
16
66
group ('getMessages' , () {
17
67
Future <GetMessagesResult > checkGetMessages (
18
68
FakeApiConnection connection, {
0 commit comments