From 87df3e28f49259c0bf51f1399760e95786f301c8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 27 Jun 2022 09:26:28 +0200 Subject: [PATCH] remove test --- .../lib/src/channel_list_core.dart | 6 +- .../lib/src/channels_bloc.dart | 2 +- .../test/channels_bloc_test.dart | 91 ------------------- 3 files changed, 5 insertions(+), 94 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart index 58e90dd1f..556b44cc6 100644 --- a/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/channel_list_core.dart @@ -32,7 +32,7 @@ import 'package:stream_chat_flutter_core/src/typedef.dart'; /// ), /// errorBuilder: (context, err) { /// return Center( -/// child: Text('An error has occurred'), +/// child: Text('An error has occured'), /// ); /// }, /// emptyBuilder: (context) { @@ -192,7 +192,7 @@ class ChannelListCoreState extends State { @override void didChangeDependencies() { - super.didChangeDependencies(); + _channelsBloc = ChannelsBloc.of(context); final newStreamChatCoreState = StreamChatCore.of(context); if (newStreamChatCoreState != _streamChatCoreState) { @@ -209,6 +209,8 @@ class ChannelListCoreState extends State { ) .listen((event) => loadData()); } + + super.didChangeDependencies(); } @override diff --git a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart index 32b51681c..561ae6f07 100644 --- a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart @@ -226,7 +226,7 @@ class ChannelsBlocState extends State .listen((e) { final channel = e.channel; _channelsController.safeAdd(List.from( - (channels ?? [])..removeWhere((c) => c.channelId == channel?.cid), + (channels ?? [])..removeWhere((c) => c.id == channel?.cid), )); })); } diff --git a/packages/stream_chat_flutter_core/test/channels_bloc_test.dart b/packages/stream_chat_flutter_core/test/channels_bloc_test.dart index 630ef8810..59d87e667 100644 --- a/packages/stream_chat_flutter_core/test/channels_bloc_test.dart +++ b/packages/stream_chat_flutter_core/test/channels_bloc_test.dart @@ -494,97 +494,6 @@ void main() { }, ); - testWidgets( - 'channel should get removed when EventType.channelDeleted or ' - 'EventType.notificationRemovedFromChannel, event is received', - (tester) async { - final mockClient = MockClient(); - const channelsBlocKey = Key('channelsBloc'); - const channelsBloc = ChannelsBloc( - key: channelsBlocKey, - child: Offstage(), - ); - - when(() => mockClient.on(any(), any(), any(), any())) - .thenAnswer((_) => const Stream.empty()); - - when(() => mockClient.on( - EventType.channelDeleted, - EventType.notificationRemovedFromChannel, - )).thenAnswer((_) => eventController.stream); - - await tester.pumpWidget( - StreamChatCore( - client: mockClient, - child: channelsBloc, - ), - ); - - final channelsBlocState = tester.state( - find.byKey(channelsBlocKey), - ); - - final channels = _generateChannels(mockClient); - - when(() => mockClient.queryChannels( - filter: any(named: 'filter'), - sort: any(named: 'sort'), - state: any(named: 'state'), - watch: any(named: 'watch'), - presence: any(named: 'presence'), - memberLimit: any(named: 'memberLimit'), - messageLimit: any(named: 'messageLimit'), - paginationParams: any(named: 'paginationParams'), - )).thenAnswer( - (_) => Stream.value(channels), - ); - - await channelsBlocState.queryChannels(); - - verify(() => mockClient.queryChannels( - filter: any(named: 'filter'), - sort: any(named: 'sort'), - state: any(named: 'state'), - watch: any(named: 'watch'), - presence: any(named: 'presence'), - memberLimit: any(named: 'memberLimit'), - messageLimit: any(named: 'messageLimit'), - paginationParams: any(named: 'paginationParams'), - )).called(1); - - final channelDeletedOrNotificationRemovedEvent = Event( - type: EventType.channelDeleted, - channel: EventChannel( - cid: channels.first.cid!, - updatedAt: DateTime.now(), - config: ChannelConfig(), - createdAt: DateTime.now(), - memberCount: 1, - ), - ); - - eventController.add(channelDeletedOrNotificationRemovedEvent); - - final channelCid = - channelDeletedOrNotificationRemovedEvent.channel?.cid; - final newChannels = [...channels] - ..removeWhere((it) => it.cid == channelCid); - - await expectLater( - channelsBlocState.channelsStream, - emitsInOrder([ - isSameChannelListAs(channels), - isSameChannelListAs(newChannels), - ]), - ); - - verify(() => mockClient.on( - EventType.channelDeleted, - EventType.notificationRemovedFromChannel, - )).called(1); - }, - ); - testWidgets( 'event channel should be moved to top of the list if present when ' 'EventType.messageNew event is received',