From 8cc6f35a635e5aef23e6bd3aa7c8c00a46f3f37b Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Fri, 27 Oct 2023 14:36:57 +0100 Subject: [PATCH] api test: Add test for markTopicAsRead --- test/api/route/messages_test.dart | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/api/route/messages_test.dart b/test/api/route/messages_test.dart index 472895b18d..2cb174e1cb 100644 --- a/test/api/route/messages_test.dart +++ b/test/api/route/messages_test.dart @@ -454,6 +454,35 @@ void main() { }); }); + group('markTopicAsRead', () { + Future checkMarkTopicAsRead( + FakeApiConnection connection, { + required int streamId, + required String topicName, + required Map expected, + }) async { + connection.prepare(json: {}); + await markTopicAsRead(connection, + streamId: streamId, topicName: topicName); + check(connection.lastRequest).isNotNull().isA() + ..method.equals('POST') + ..url.path.equals('/api/v1/mark_topic_as_read') + ..bodyFields.deepEquals(expected); + } + + test('smoke', () { + return FakeApiConnection.with_((connection) async { + await checkMarkTopicAsRead(connection, + streamId: 10, + topicName: 'topic', + expected: { + 'stream_id': '10', + 'topic_name': 'topic', + }); + }); + }); + }); + group('updateMessageFlags', () { Future checkUpdateMessageFlags( FakeApiConnection connection, {