@@ -15,118 +15,6 @@ import '../fake_api.dart';
15
15
import 'route_checks.dart' ;
16
16
17
17
void main () {
18
- group ('getMessageCompat' , () {
19
- Future <Message ?> checkGetMessageCompat (FakeApiConnection connection, {
20
- required bool expectLegacy,
21
- required int messageId,
22
- bool ? applyMarkdown,
23
- required bool allowEmptyTopicName,
24
- }) async {
25
- final result = await getMessageCompat (connection,
26
- messageId: messageId,
27
- applyMarkdown: applyMarkdown,
28
- allowEmptyTopicName: allowEmptyTopicName,
29
- );
30
- if (expectLegacy) {
31
- check (connection.lastRequest).isA< http.Request > ()
32
- ..method.equals ('GET' )
33
- ..url.path.equals ('/api/v1/messages' )
34
- ..url.queryParameters.deepEquals ({
35
- 'narrow' : jsonEncode ([ApiNarrowMessageId (messageId)]),
36
- 'anchor' : messageId.toString (),
37
- 'num_before' : '0' ,
38
- 'num_after' : '0' ,
39
- if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
40
- 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
41
- 'client_gravatar' : 'true' ,
42
- });
43
- } else {
44
- check (connection.lastRequest).isA< http.Request > ()
45
- ..method.equals ('GET' )
46
- ..url.path.equals ('/api/v1/messages/$messageId ' )
47
- ..url.queryParameters.deepEquals ({
48
- if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
49
- 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
50
- });
51
- }
52
- return result;
53
- }
54
-
55
- test ('modern; message found' , () {
56
- return FakeApiConnection .with_ ((connection) async {
57
- final message = eg.streamMessage ();
58
- final fakeResult = GetMessageResult (message: message);
59
- connection.prepare (json: fakeResult.toJson ());
60
- final result = await checkGetMessageCompat (connection,
61
- expectLegacy: false ,
62
- messageId: message.id,
63
- applyMarkdown: true ,
64
- allowEmptyTopicName: true ,
65
- );
66
- check (result).isNotNull ().jsonEquals (message);
67
- });
68
- });
69
-
70
- test ('modern; message not found' , () {
71
- return FakeApiConnection .with_ ((connection) async {
72
- final message = eg.streamMessage ();
73
- connection.prepare (
74
- apiException: eg.apiBadRequest (message: 'Invalid message(s)' ));
75
- final result = await checkGetMessageCompat (connection,
76
- expectLegacy: false ,
77
- messageId: message.id,
78
- applyMarkdown: true ,
79
- allowEmptyTopicName: true ,
80
- );
81
- check (result).isNull ();
82
- });
83
- });
84
-
85
- test ('legacy; message found' , () {
86
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
87
- final message = eg.streamMessage ();
88
- final fakeResult = GetMessagesResult (
89
- anchor: message.id,
90
- foundNewest: false ,
91
- foundOldest: false ,
92
- foundAnchor: true ,
93
- historyLimited: false ,
94
- messages: [message],
95
- );
96
- connection.prepare (json: fakeResult.toJson ());
97
- final result = await checkGetMessageCompat (connection,
98
- expectLegacy: true ,
99
- messageId: message.id,
100
- applyMarkdown: true ,
101
- allowEmptyTopicName: true ,
102
- );
103
- check (result).isNotNull ().jsonEquals (message);
104
- });
105
- });
106
-
107
- test ('legacy; message not found' , () {
108
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
109
- final message = eg.streamMessage ();
110
- final fakeResult = GetMessagesResult (
111
- anchor: message.id,
112
- foundNewest: false ,
113
- foundOldest: false ,
114
- foundAnchor: false ,
115
- historyLimited: false ,
116
- messages: [],
117
- );
118
- connection.prepare (json: fakeResult.toJson ());
119
- final result = await checkGetMessageCompat (connection,
120
- expectLegacy: true ,
121
- messageId: message.id,
122
- applyMarkdown: true ,
123
- allowEmptyTopicName: true ,
124
- );
125
- check (result).isNull ();
126
- });
127
- });
128
- });
129
-
130
18
group ('getMessage' , () {
131
19
Future <GetMessageResult > checkGetMessage (
132
20
FakeApiConnection connection, {
@@ -186,16 +74,6 @@ void main() {
186
74
expected: {'allow_empty_topic_name' : 'true' });
187
75
});
188
76
});
189
-
190
- test ('Throws assertion error when FL <120' , () {
191
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
192
- connection.prepare (json: fakeResult.toJson ());
193
- check (() => getMessage (connection,
194
- messageId: 1 ,
195
- allowEmptyTopicName: true ,
196
- )).throws <AssertionError >();
197
- });
198
- });
199
77
});
200
78
201
79
test ('ApiNarrow.toJson' , () {
0 commit comments