Skip to content

Commit

Permalink
remove test
Browse files Browse the repository at this point in the history
  • Loading branch information
imtoori committed Jun 27, 2022
1 parent ae6e19a commit 87df3e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -192,7 +192,7 @@ class ChannelListCoreState extends State<ChannelListCore> {

@override
void didChangeDependencies() {
super.didChangeDependencies();
_channelsBloc = ChannelsBloc.of(context);
final newStreamChatCoreState = StreamChatCore.of(context);

if (newStreamChatCoreState != _streamChatCoreState) {
Expand All @@ -209,6 +209,8 @@ class ChannelListCoreState extends State<ChannelListCore> {
)
.listen((event) => loadData());
}

super.didChangeDependencies();
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class ChannelsBlocState extends State<ChannelsBloc>
.listen((e) {
final channel = e.channel;
_channelsController.safeAdd(List.from(
(channels ?? [])..removeWhere((c) => c.channelId == channel?.cid),
(channels ?? <Channel>[])..removeWhere((c) => c.id == channel?.cid),
));
}));
}
Expand Down
91 changes: 0 additions & 91 deletions packages/stream_chat_flutter_core/test/channels_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChannelsBlocState>(
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',
Expand Down

0 comments on commit 87df3e2

Please sign in to comment.