From b920919e0f872ea9d808cfe15156cc5d1ba0bb7a Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 19 Aug 2021 17:20:59 +0530 Subject: [PATCH] added tests --- .../test/src/api/channel_test.dart | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/stream_chat/test/src/api/channel_test.dart b/packages/stream_chat/test/src/api/channel_test.dart index 7c5386c6..6afa60c2 100644 --- a/packages/stream_chat/test/src/api/channel_test.dart +++ b/packages/stream_chat/test/src/api/channel_test.dart @@ -1859,6 +1859,52 @@ void main() { ).called(1); }); + test('`.enableSlowMode`', () async { + final channelModel = ChannelModel( + cid: channelCid, + cooldown: 10, + ); + + when(() => client.enableSlowdown( + channelCid, + channelType, + 10, + )).thenAnswer((_) async => PartialUpdateChannelResponse() + ..channel = channelModel); + + final res = await channel.enableSlowMode(cooldownInterval: 10); + + expect(res, isNotNull); + + verify(() => client.enableSlowdown( + channelCid, + channelType, + any(), + )).called(1); + }); + + test('`.disableSlowMode`', () async { + final channelModel = ChannelModel( + cid: channelCid, + cooldown: 0, + ); + + when(() => client.disableSlowdown( + channelCid, + channelType, + )).thenAnswer((_) async => PartialUpdateChannelResponse() + ..channel = channelModel); + + final res = await channel.disableSlowMode(); + + expect(res, isNotNull); + + verify(() => client.disableSlowdown( + channelCid, + channelType, + )).called(1); + }); + test('`.banUser`', () async { const userId = 'test-user-id'; const options = {'key': 'value'};