@@ -15,110 +15,6 @@ import '../fake_api.dart';
1515import 'route_checks.dart' ;
1616
1717void 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- connection.prepare (
69- apiException: eg.apiBadRequest (message: 'Invalid message(s)' ));
70- final result = await checkGetMessageCompat (connection,
71- expectLegacy: false ,
72- messageId: message.id,
73- applyMarkdown: true ,
74- );
75- check (result).isNull ();
76- });
77- });
78-
79- test ('legacy; message found' , () {
80- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
81- final message = eg.streamMessage ();
82- final fakeResult = GetMessagesResult (
83- anchor: message.id,
84- foundNewest: false ,
85- foundOldest: false ,
86- foundAnchor: true ,
87- historyLimited: false ,
88- messages: [message],
89- );
90- connection.prepare (json: fakeResult.toJson ());
91- final result = await checkGetMessageCompat (connection,
92- expectLegacy: true ,
93- messageId: message.id,
94- applyMarkdown: true ,
95- );
96- check (result).isNotNull ().jsonEquals (message);
97- });
98- });
99-
100- test ('legacy; message not found' , () {
101- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
102- final message = eg.streamMessage ();
103- final fakeResult = GetMessagesResult (
104- anchor: message.id,
105- foundNewest: false ,
106- foundOldest: false ,
107- foundAnchor: false ,
108- historyLimited: false ,
109- messages: [],
110- );
111- connection.prepare (json: fakeResult.toJson ());
112- final result = await checkGetMessageCompat (connection,
113- expectLegacy: true ,
114- messageId: message.id,
115- applyMarkdown: true ,
116- );
117- check (result).isNull ();
118- });
119- });
120- });
121-
12218 group ('getMessage' , () {
12319 Future <GetMessageResult > checkGetMessage (
12420 FakeApiConnection connection, {
@@ -158,15 +54,6 @@ void main() {
15854 expected: {'apply_markdown' : 'false' });
15955 });
16056 });
161-
162- test ('Throws assertion error when FL <120' , () {
163- return FakeApiConnection .with_ (zulipFeatureLevel: 119 , (connection) async {
164- connection.prepare (json: fakeResult.toJson ());
165- check (() => getMessage (connection,
166- messageId: 1 ,
167- )).throws <AssertionError >();
168- });
169- });
17057 });
17158
17259 test ('ApiNarrow.toJson' , () {
0 commit comments