@@ -15,114 +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
- }) async {
24
- final result = await getMessageCompat (connection,
25
- messageId: messageId,
26
- applyMarkdown: applyMarkdown,
27
- );
28
- if (expectLegacy) {
29
- check (connection.lastRequest).isA< http.Request > ()
30
- ..method.equals ('GET' )
31
- ..url.path.equals ('/api/v1/messages' )
32
- ..url.queryParameters.deepEquals ({
33
- 'narrow' : jsonEncode ([ApiNarrowMessageId (messageId)]),
34
- 'anchor' : messageId.toString (),
35
- 'num_before' : '0' ,
36
- 'num_after' : '0' ,
37
- if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
38
- 'client_gravatar' : 'true' ,
39
- });
40
- } else {
41
- check (connection.lastRequest).isA< http.Request > ()
42
- ..method.equals ('GET' )
43
- ..url.path.equals ('/api/v1/messages/$messageId ' )
44
- ..url.queryParameters.deepEquals ({
45
- if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
46
- });
47
- }
48
- return result;
49
- }
50
-
51
- test ('modern; message found' , () {
52
- return FakeApiConnection .with_ ((connection) async {
53
- final message = eg.streamMessage ();
54
- final fakeResult = GetMessageResult (message: message);
55
- connection.prepare (json: fakeResult.toJson ());
56
- final result = await checkGetMessageCompat (connection,
57
- expectLegacy: false ,
58
- messageId: message.id,
59
- applyMarkdown: true ,
60
- );
61
- check (result).isNotNull ().jsonEquals (message);
62
- });
63
- });
64
-
65
- test ('modern; message not found' , () {
66
- return FakeApiConnection .with_ ((connection) async {
67
- final message = eg.streamMessage ();
68
- final fakeResponseJson = {
69
- 'code' : 'BAD_REQUEST' ,
70
- 'msg' : 'Invalid message(s)' ,
71
- 'result' : 'error' ,
72
- };
73
- connection.prepare (httpStatus: 400 , json: fakeResponseJson);
74
- final result = await checkGetMessageCompat (connection,
75
- expectLegacy: false ,
76
- messageId: message.id,
77
- applyMarkdown: true ,
78
- );
79
- check (result).isNull ();
80
- });
81
- });
82
-
83
- test ('legacy; message found' , () {
84
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
85
- final message = eg.streamMessage ();
86
- final fakeResult = GetMessagesResult (
87
- anchor: message.id,
88
- foundNewest: false ,
89
- foundOldest: false ,
90
- foundAnchor: true ,
91
- historyLimited: false ,
92
- messages: [message],
93
- );
94
- connection.prepare (json: fakeResult.toJson ());
95
- final result = await checkGetMessageCompat (connection,
96
- expectLegacy: true ,
97
- messageId: message.id,
98
- applyMarkdown: true ,
99
- );
100
- check (result).isNotNull ().jsonEquals (message);
101
- });
102
- });
103
-
104
- test ('legacy; message not found' , () {
105
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
106
- final message = eg.streamMessage ();
107
- final fakeResult = GetMessagesResult (
108
- anchor: message.id,
109
- foundNewest: false ,
110
- foundOldest: false ,
111
- foundAnchor: false ,
112
- historyLimited: false ,
113
- messages: [],
114
- );
115
- connection.prepare (json: fakeResult.toJson ());
116
- final result = await checkGetMessageCompat (connection,
117
- expectLegacy: true ,
118
- messageId: message.id,
119
- applyMarkdown: true ,
120
- );
121
- check (result).isNull ();
122
- });
123
- });
124
- });
125
-
126
18
group ('getMessage' , () {
127
19
Future <GetMessageResult > checkGetMessage (
128
20
FakeApiConnection connection, {
@@ -162,15 +54,6 @@ void main() {
162
54
expected: {'apply_markdown' : 'false' });
163
55
});
164
56
});
165
-
166
- test ('Throws assertion error when FL <120' , () {
167
- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
168
- connection.prepare (json: fakeResult.toJson ());
169
- check (() => getMessage (connection,
170
- messageId: 1 ,
171
- )).throws <AssertionError >();
172
- });
173
- });
174
57
});
175
58
176
59
test ('Narrow.toJson' , () {
0 commit comments