chore: apply linter to the various example and test directories (#550)
* chore: remove examples and tests from analysis exclusion * chore: apply linter fixes to stream_chat_flutter_core/example/main.dart * chore: apply linter fixes to stream_chat_flutter/example/main.dart * chore: apply linter fixes to stream_chat_persistence/example/main.dart * chore: apply linter fixes to stream_chat/example/main.dart * chore: apply linter fixes to stream_chat_flutter/example/split_view.dart * chore: renamte tutorial files per linter * chore: apply linter fixes to tutorial_part_1.dart * chore: apply linter fixes to tutorial_part_2.dart * chore: apply linter fixes to tutorial_part_3.dart * chore: apply linter fixes to tutorial_part_4.dart * chore: apply linter fixes to tutorial_part_5.dart * chore: make a widget const in tutorial_part_5.dart * chore: apply linter fixes to tutorial_part_6.dart * chore: sort and update dependencies in stream_chat_persistence/example/pubspec.yaml * chore: sort and update dependencies in stream_chat_flutter_core/example/pubspec.yaml * chore: sort and update dependencies in stream_chat_flutter/example/pubspec.yaml * chore: sort dependencies in stream_chat_flutter/example/pubspec.yaml * chore: apply linter fixes to channel_test.dart * chore: apply linter fixes to client_test.dart * chore: apply linter fixes to client_test.dart, stream_http_client_test.dart, and token_manager_test.dart * chore: apply linter fixes to filter_test.dart * chore: apply linter fixes to reaction_test.dart * chore: apply linter fixes to chat_persistence_client_test.dart * chore: apply linter fixes to channel_image_test.dart * chore: apply linter fixes to deleted_message_test.dart * chore: apply linter fixes to full_screen_media_test.dart * chore: apply linter fixes to gallery_footer_theme_test.dart * chore: apply linter fixes to gallery_header_theme_test.dart * chore: apply linter fixes to message_text_test.dart * chore: apply linter fixes to reaction_bubble_test.dart * chore: apply linter fixes to system_message_test.dart * chore: apply linter fixes to typing_indicator_test.dart * chore: apply linter fixes to channel_list_core_test.dart * chore: apply linter fixes to channels_bloc_test.dart * chore: apply linter fixes to lazy_load_scroll_view_test.dart * chore: apply linter fixes to channel_matcher.dart * chore: apply linter fixes to message_matcher.dart * chore: apply linter fixes to users_matcher.dart * chore: apply linter fixes to message_list_core_test.dart * chore: apply linter fixes to message_search_bloc_test.dart * chore: apply linter fixes to message_search_list_core_test.dart * chore: apply linter fixes to stream_channel_test.dart * chore: apply linter fixes to stream_chat_core_test.dart * chore: apply linter fixes to user_list_core_test.dart * chore: apply linter fixes to channel_query_dao_test.dart, message_mapper_test.dart, user_mapper_test.dart, and users_bloc_test.dart * chore: apply some missed dartfmt * test: regenerate failinggolden test
This commit is contained in:
@@ -9,26 +9,25 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
void main() {
|
||||
const pagination = PaginationParams(offset: 0, limit: 3);
|
||||
const pagination = PaginationParams(limit: 3);
|
||||
|
||||
List<Channel> _generateChannels(
|
||||
StreamChatClient client, {
|
||||
int count = 3,
|
||||
int offset = 0,
|
||||
}) {
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return Channel(
|
||||
client,
|
||||
'testType$index',
|
||||
'testId$index',
|
||||
extraData: {'extra_data_key': 'extra_data_value_$index'},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return Channel(
|
||||
client,
|
||||
'testType$index',
|
||||
'testId$index',
|
||||
extraData: {'extra_data_key': 'extra_data_value_$index'},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should throw if ChannelListCore is used where ChannelsBloc is not present '
|
||||
@@ -37,10 +36,10 @@ void main() {
|
||||
const channelListCoreKey = Key('channelListCore');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(channelListCore);
|
||||
@@ -56,16 +55,16 @@ void main() {
|
||||
const channelListCoreKey = Key('channelListCore');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -88,10 +87,10 @@ void main() {
|
||||
final controller = ChannelListController();
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
channelListController: controller,
|
||||
);
|
||||
|
||||
@@ -101,7 +100,7 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -125,9 +124,9 @@ void main() {
|
||||
const errorWidgetKey = Key('errorWidget');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) =>
|
||||
Container(key: errorWidgetKey),
|
||||
pagination: pagination,
|
||||
@@ -136,7 +135,7 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
const error = 'Error! Error! Error!';
|
||||
when(() => mockClient.queryChannels(
|
||||
@@ -177,23 +176,23 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should build empty widget if channelsBlocState.channelsStream emits empty data',
|
||||
'''should build empty widget if channelsBlocState.channelsStream emits empty data''',
|
||||
(tester) async {
|
||||
const channelListCoreKey = Key('channelListCore');
|
||||
const emptyWidgetKey = Key('emptyWidget');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Container(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
pagination: pagination,
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
const channels = <Channel>[];
|
||||
when(() => mockClient.queryChannels(
|
||||
@@ -234,23 +233,23 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should build list widget if channelsBlocState.channelsStream emits some data',
|
||||
'''should build list widget if channelsBlocState.channelsStream emits some data''',
|
||||
(tester) async {
|
||||
const channelListCoreKey = Key('channelListCore');
|
||||
const listWidgetKey = Key('listWidget');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, __) => Container(key: listWidgetKey),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
pagination: pagination,
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
final channels = _generateChannels(mockClient);
|
||||
when(() => mockClient.queryChannels(
|
||||
@@ -298,24 +297,22 @@ void main() {
|
||||
const listWidgetKey = Key('listWidget');
|
||||
final channelListCore = ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, channels) {
|
||||
return Container(
|
||||
key: listWidgetKey,
|
||||
child: Text(
|
||||
channels.map((e) => e.cid).join(','),
|
||||
),
|
||||
);
|
||||
},
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, channels) => Container(
|
||||
key: listWidgetKey,
|
||||
child: Text(
|
||||
channels.map((e) => e.cid).join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
pagination: pagination,
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
final channels = _generateChannels(mockClient);
|
||||
when(() => mockClient.queryChannels(
|
||||
@@ -413,24 +410,23 @@ void main() {
|
||||
|
||||
ChannelListCore channelListCoreBuilder(int limit) => ChannelListCore(
|
||||
key: channelListCoreKey,
|
||||
listBuilder: (_, channels) {
|
||||
return Container(
|
||||
key: listWidgetKey,
|
||||
child: Text(
|
||||
channels.map((e) => e.cid).join(','),
|
||||
),
|
||||
);
|
||||
},
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, channels) => Container(
|
||||
key: listWidgetKey,
|
||||
child: Text(
|
||||
channels.map((e) => e.cid).join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) =>
|
||||
const Offstage(),
|
||||
pagination: pagination.copyWith(limit: limit),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
final channels = _generateChannels(mockClient);
|
||||
when(() => mockClient.queryChannels(
|
||||
|
||||
@@ -17,27 +17,26 @@ void main() {
|
||||
StreamChatClient client, {
|
||||
int count = 3,
|
||||
int offset = 0,
|
||||
}) {
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return Channel(
|
||||
client,
|
||||
'testType$index',
|
||||
'testId$index',
|
||||
extraData: {'extra_data_key': 'extra_data_value_$index'},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return Channel(
|
||||
client,
|
||||
'testType$index',
|
||||
'testId$index',
|
||||
extraData: {'extra_data_key': 'extra_data_value_$index'},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should throw if ChannelsBloc is used where StreamChat is not present in the widget tree',
|
||||
'''should throw if ChannelsBloc is used where StreamChat is not present in the widget tree''',
|
||||
(tester) async {
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
const childKey = Key('child');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -55,7 +54,7 @@ void main() {
|
||||
(tester) async {
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
const childKey = Key('child');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -63,7 +62,7 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -86,16 +85,14 @@ void main() {
|
||||
key: channelsBlocKey,
|
||||
child: Builder(
|
||||
key: childKey,
|
||||
builder: (context) {
|
||||
return Offstage();
|
||||
},
|
||||
builder: (context) => const Offstage(),
|
||||
),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -157,16 +154,14 @@ void main() {
|
||||
key: channelsBlocKey,
|
||||
child: Builder(
|
||||
key: childKey,
|
||||
builder: (context) {
|
||||
return Offstage();
|
||||
},
|
||||
builder: (context) => const Offstage(),
|
||||
),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -218,7 +213,7 @@ void main() {
|
||||
'through queryChannelsLoading',
|
||||
(tester) async {
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
@@ -226,7 +221,7 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -323,7 +318,7 @@ void main() {
|
||||
'client.queryChannels() throws',
|
||||
(tester) async {
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
@@ -331,7 +326,7 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
await tester.pumpWidget(
|
||||
StreamChatCore(
|
||||
@@ -345,7 +340,7 @@ void main() {
|
||||
);
|
||||
|
||||
final channels = _generateChannels(mockClient);
|
||||
final paginationParams = const PaginationParams(
|
||||
const paginationParams = PaginationParams(
|
||||
limit: 3,
|
||||
);
|
||||
|
||||
@@ -380,7 +375,7 @@ void main() {
|
||||
paginationParams: paginationParams,
|
||||
)).called(1);
|
||||
|
||||
final error = 'Error! Error! Error!';
|
||||
const error = 'Error! Error! Error!';
|
||||
|
||||
when(() => mockClient.queryChannels(
|
||||
filter: any(named: 'filter'),
|
||||
@@ -424,13 +419,13 @@ void main() {
|
||||
(tester) async {
|
||||
final mockClient = MockClient();
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.channelHidden,
|
||||
@@ -503,13 +498,13 @@ void main() {
|
||||
(tester) async {
|
||||
final mockClient = MockClient();
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.channelDeleted,
|
||||
@@ -589,18 +584,18 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'event channel should be moved to top of the list if present when'
|
||||
'event channel should be moved to top of the list if present when '
|
||||
'EventType.messageNew event is received',
|
||||
(tester) async {
|
||||
final mockClient = MockClient();
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
const channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.messageNew,
|
||||
@@ -678,21 +673,19 @@ void main() {
|
||||
(tester) async {
|
||||
final hiddenChannelEventController = StreamController<Event>();
|
||||
|
||||
addTearDown(() {
|
||||
hiddenChannelEventController.close();
|
||||
});
|
||||
addTearDown(hiddenChannelEventController.close);
|
||||
|
||||
final mockClient = MockClient();
|
||||
final channels = _generateChannels(mockClient);
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
shouldAddChannel: (e) => channels.map((it) => it.cid).contains(e.cid),
|
||||
child: const Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.channelHidden,
|
||||
@@ -789,14 +782,14 @@ void main() {
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
shouldAddChannel: (_) => true,
|
||||
child: const Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.state.channels).thenReturn(stateChannels);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.messageNew,
|
||||
@@ -868,21 +861,21 @@ void main() {
|
||||
final mockClient = MockClient();
|
||||
final channels = _generateChannels(mockClient);
|
||||
int channelComparator(Channel a, Channel b) {
|
||||
final aData = a.extraData['extra_data_key'] as String;
|
||||
final bData = b.extraData['extra_data_key'] as String;
|
||||
final aData = a.extraData['extra_data_key'].toString();
|
||||
final bData = b.extraData['extra_data_key'].toString();
|
||||
return bData.compareTo(aData);
|
||||
}
|
||||
|
||||
const channelsBlocKey = Key('channelsBloc');
|
||||
final channelsBloc = ChannelsBloc(
|
||||
key: channelsBlocKey,
|
||||
child: Offstage(),
|
||||
shouldAddChannel: (_) => true,
|
||||
channelsComparator: channelComparator,
|
||||
child: const Offstage(),
|
||||
);
|
||||
|
||||
when(() => mockClient.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => Stream.empty());
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
|
||||
when(() => mockClient.on(
|
||||
EventType.messageNew,
|
||||
|
||||
@@ -7,7 +7,7 @@ void main() {
|
||||
'should render LazyLoadScrollView if child is provided',
|
||||
(tester) async {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
const lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
child: Offstage(),
|
||||
);
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
(tester) async {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childKey = Key('childKey');
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
const lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childListViewKey = Key('childListView');
|
||||
|
||||
bool onPageScrollStartCalled = false;
|
||||
var onPageScrollStartCalled = false;
|
||||
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
@@ -52,7 +52,7 @@ void main() {
|
||||
key: childListViewKey,
|
||||
children: List.generate(
|
||||
12,
|
||||
(index) => Container(
|
||||
(index) => SizedBox(
|
||||
height: 100,
|
||||
child: Text('Item #$index'),
|
||||
),
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
expect(find.byKey(childListViewKey), findsOneWidget);
|
||||
expect(onPageScrollStartCalled, isFalse);
|
||||
|
||||
await tester.startGesture(const Offset(100.0, 100.0));
|
||||
await tester.startGesture(const Offset(100, 100));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(onPageScrollStartCalled, isTrue);
|
||||
@@ -85,8 +85,8 @@ void main() {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childListViewKey = Key('childListView');
|
||||
|
||||
bool onPageScrollStartCalled = false;
|
||||
bool onPageScrollEndCalled = false;
|
||||
var onPageScrollStartCalled = false;
|
||||
var onPageScrollEndCalled = false;
|
||||
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
@@ -100,7 +100,7 @@ void main() {
|
||||
key: childListViewKey,
|
||||
children: List.generate(
|
||||
12,
|
||||
(index) => Container(
|
||||
(index) => SizedBox(
|
||||
height: 100,
|
||||
child: Text('Item #$index'),
|
||||
),
|
||||
@@ -122,7 +122,7 @@ void main() {
|
||||
|
||||
final gesture = await tester.createGesture();
|
||||
|
||||
await gesture.down(const Offset(100.0, 100.0));
|
||||
await gesture.down(const Offset(100, 100));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(onPageScrollStartCalled, isTrue);
|
||||
@@ -141,7 +141,7 @@ void main() {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childListViewKey = Key('childListView');
|
||||
|
||||
bool onInBetweenOfPageCalled = false;
|
||||
var onInBetweenOfPageCalled = false;
|
||||
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
@@ -152,7 +152,7 @@ void main() {
|
||||
key: childListViewKey,
|
||||
children: List.generate(
|
||||
12,
|
||||
(index) => Container(
|
||||
(index) => SizedBox(
|
||||
height: 100,
|
||||
child: Text('Item #$index'),
|
||||
),
|
||||
@@ -173,9 +173,9 @@ void main() {
|
||||
|
||||
final gesture = await tester.createGesture();
|
||||
|
||||
await gesture.down(const Offset(100.0, 100.0));
|
||||
await gesture.down(const Offset(100, 100));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await gesture.moveBy(const Offset(-200.0, -200.0));
|
||||
await gesture.moveBy(const Offset(-200, -200));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(onInBetweenOfPageCalled, isTrue);
|
||||
@@ -189,7 +189,7 @@ void main() {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childListViewKey = Key('childListView');
|
||||
|
||||
bool onStartOfPageCalled = false;
|
||||
var onStartOfPageCalled = false;
|
||||
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
@@ -200,7 +200,7 @@ void main() {
|
||||
key: childListViewKey,
|
||||
children: List.generate(
|
||||
12,
|
||||
(index) => Container(
|
||||
(index) => SizedBox(
|
||||
height: 100,
|
||||
child: Text('Item #$index'),
|
||||
),
|
||||
@@ -221,11 +221,11 @@ void main() {
|
||||
|
||||
final gesture = await tester.createGesture();
|
||||
|
||||
await gesture.down(const Offset(100.0, 100.0));
|
||||
await gesture.down(const Offset(100, 100));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await gesture.moveBy(const Offset(-200.0, -200.0));
|
||||
await gesture.moveBy(const Offset(-200, -200));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await gesture.moveBy(const Offset(201.0, 201.0));
|
||||
await gesture.moveBy(const Offset(201, 201));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(onStartOfPageCalled, isTrue);
|
||||
@@ -239,7 +239,7 @@ void main() {
|
||||
const lazyLoadScrollViewKey = Key('lazyLoadScrollView');
|
||||
const childListViewKey = Key('childListView');
|
||||
|
||||
bool onEndOfPageCalled = false;
|
||||
var onEndOfPageCalled = false;
|
||||
|
||||
final lazyLoadScrollView = LazyLoadScrollView(
|
||||
key: lazyLoadScrollViewKey,
|
||||
@@ -250,7 +250,7 @@ void main() {
|
||||
key: childListViewKey,
|
||||
children: List.generate(
|
||||
12,
|
||||
(index) => Container(
|
||||
(index) => SizedBox(
|
||||
height: 100,
|
||||
child: Text('Item #$index'),
|
||||
),
|
||||
@@ -271,9 +271,9 @@ void main() {
|
||||
|
||||
final gesture = await tester.createGesture();
|
||||
|
||||
await gesture.down(const Offset(100.0, 100.0));
|
||||
await gesture.down(const Offset(100, 100));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await gesture.moveBy(const Offset(-601.0, -601.0));
|
||||
await gesture.moveBy(const Offset(-601, -601));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(onEndOfPageCalled, isTrue);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
@@ -8,7 +7,7 @@ Matcher isSameChannelAs(Channel targetChannel) =>
|
||||
class _IsSameChannelAs extends Matcher {
|
||||
const _IsSameChannelAs({
|
||||
required this.targetChannel,
|
||||
}) : assert(targetChannel != null, '');
|
||||
});
|
||||
|
||||
final Channel targetChannel;
|
||||
|
||||
@@ -27,13 +26,13 @@ Matcher isSameChannelListAs(List<Channel> targetChannelList) =>
|
||||
class _IsSameChannelListAs extends Matcher {
|
||||
const _IsSameChannelListAs({
|
||||
required this.targetChannelList,
|
||||
}) : assert(targetChannelList != null, '');
|
||||
});
|
||||
|
||||
final List<Channel> targetChannelList;
|
||||
|
||||
@override
|
||||
bool matches(covariant List<Channel> channelList, Map matchState) {
|
||||
bool matches = true;
|
||||
var matches = true;
|
||||
for (var i = 0; i < channelList.length; i++) {
|
||||
final channel = channelList[i];
|
||||
final targetChannel = targetChannelList[i];
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
@@ -8,7 +7,7 @@ Matcher isSameMessageAs(Message targetMessage) =>
|
||||
class _IsSameMessageAs extends Matcher {
|
||||
const _IsSameMessageAs({
|
||||
required this.targetMessage,
|
||||
}) : assert(targetMessage != null, '');
|
||||
});
|
||||
|
||||
final Message targetMessage;
|
||||
|
||||
@@ -27,13 +26,13 @@ Matcher isSameMessageListAs(List<Message> targetMessageList) =>
|
||||
class _IsSameMessageListAs extends Matcher {
|
||||
const _IsSameMessageListAs({
|
||||
required this.targetMessageList,
|
||||
}) : assert(targetMessageList != null, '');
|
||||
});
|
||||
|
||||
final List<Message> targetMessageList;
|
||||
|
||||
@override
|
||||
bool matches(covariant List<Message> messageList, Map matchState) {
|
||||
bool matches = true;
|
||||
var matches = true;
|
||||
for (var i = 0; i < messageList.length; i++) {
|
||||
final message = messageList[i];
|
||||
final targetMessage = targetMessageList[i];
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
@@ -7,7 +6,7 @@ Matcher isSameUserAs(User targetUser) => _IsSameUserAs(targetUser: targetUser);
|
||||
class _IsSameUserAs extends Matcher {
|
||||
const _IsSameUserAs({
|
||||
required this.targetUser,
|
||||
}) : assert(targetUser != null, '');
|
||||
});
|
||||
|
||||
final User targetUser;
|
||||
|
||||
@@ -25,13 +24,13 @@ Matcher isSameUserListAs(List<User> targetUserList) =>
|
||||
class _IsSameUserListAs extends Matcher {
|
||||
const _IsSameUserListAs({
|
||||
required this.targetUserList,
|
||||
}) : assert(targetUserList != null, '');
|
||||
});
|
||||
|
||||
final List<User> targetUserList;
|
||||
|
||||
@override
|
||||
bool matches(covariant List<User> userList, Map matchState) {
|
||||
bool matches = true;
|
||||
var matches = true;
|
||||
for (var i = 0; i < userList.length; i++) {
|
||||
final user = userList[i];
|
||||
final targetUser = targetUserList[i];
|
||||
|
||||
@@ -27,10 +27,9 @@ void main() {
|
||||
type: 'testType',
|
||||
user: users[index],
|
||||
createdAt: DateTime.now(),
|
||||
shadowed: false,
|
||||
replyCount: index,
|
||||
updatedAt: DateTime.now(),
|
||||
extraData: {'extra_test_field': 'extraTestData'},
|
||||
extraData: const {'extra_test_field': 'extraTestData'},
|
||||
text: 'Dummy text #$index',
|
||||
pinned: true,
|
||||
pinnedAt: DateTime.now(),
|
||||
@@ -48,10 +47,9 @@ void main() {
|
||||
user: users[index],
|
||||
parentId: messages[0].id,
|
||||
createdAt: DateTime.now(),
|
||||
shadowed: false,
|
||||
replyCount: index,
|
||||
updatedAt: DateTime.now(),
|
||||
extraData: {'extra_test_field': 'extraTestData'},
|
||||
extraData: const {'extra_test_field': 'extraTestData'},
|
||||
text: 'Dummy text #$index',
|
||||
pinned: true,
|
||||
pinnedAt: DateTime.now(),
|
||||
@@ -63,16 +61,15 @@ void main() {
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'should throw if MessageListCore is used where StreamChannel is not present '
|
||||
'in the widget tree',
|
||||
'''should throw if MessageListCore is used where StreamChannel is not present in the widget tree''',
|
||||
(tester) async {
|
||||
const messageListCoreKey = Key('messageListCore');
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(messageListCore);
|
||||
@@ -88,10 +85,10 @@ void main() {
|
||||
const messageListCoreKey = Key('messageListCore');
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockChannel = MockChannel();
|
||||
@@ -120,10 +117,10 @@ void main() {
|
||||
final controller = MessageListController();
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
messageListController: controller,
|
||||
);
|
||||
|
||||
@@ -150,16 +147,16 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should assign paginateData callback and paginate data correctly if a MessageListController is passed',
|
||||
'''should assign paginateData callback and paginate data correctly if a MessageListController is passed''',
|
||||
(tester) async {
|
||||
const messageListCoreKey = Key('messageListCore');
|
||||
final controller = MessageListController();
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
messageListController: controller,
|
||||
);
|
||||
|
||||
@@ -207,10 +204,10 @@ void main() {
|
||||
const errorWidgetKey = Key('errorWidget');
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(
|
||||
key: errorWidgetKey,
|
||||
),
|
||||
);
|
||||
@@ -249,10 +246,11 @@ void main() {
|
||||
const emptyWidgetKey = Key('emptyWidget');
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) =>
|
||||
const Offstage(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockChannel = MockChannel();
|
||||
@@ -289,10 +287,10 @@ void main() {
|
||||
const listWidgetKey = Key('listWidget');
|
||||
final messageListCore = MessageListCore(
|
||||
key: messageListCoreKey,
|
||||
messageListBuilder: (_, __) => Offstage(key: listWidgetKey),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
messageListBuilder: (_, __) => const Offstage(key: listWidgetKey),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockChannel = MockChannel();
|
||||
@@ -344,9 +342,9 @@ void main() {
|
||||
messages.reversed.map((it) => it.id).join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockChannel = MockChannel();
|
||||
@@ -391,9 +389,9 @@ void main() {
|
||||
messages.reversed.map((it) => '${it.parentId}-${it.id}').join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
parentMessage: parentMessage,
|
||||
);
|
||||
|
||||
|
||||
@@ -8,34 +8,33 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'matchers/get_message_response_matcher.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
final testFilter = Filter.custom(operator: '\$test', value: 'testValue');
|
||||
const testFilter = Filter.custom(operator: '\$test', value: 'testValue');
|
||||
|
||||
void main() {
|
||||
List<GetMessageResponse> _generateMessages({
|
||||
int count = 3,
|
||||
int offset = 0,
|
||||
}) {
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return GetMessageResponse()
|
||||
..message = Message(
|
||||
id: 'testId$index',
|
||||
text: 'testTextData$index',
|
||||
)
|
||||
..channel = ChannelModel(
|
||||
cid: 'testCid:id',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return GetMessageResponse()
|
||||
..message = Message(
|
||||
id: 'testId$index',
|
||||
text: 'testTextData$index',
|
||||
)
|
||||
..channel = ChannelModel(
|
||||
cid: 'testCid:id',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'messageSearchBlocState.search() should throw if used where '
|
||||
'StreamChat is not present in the widget tree',
|
||||
(tester) async {
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
const messageSearchBloc = MessageSearchBloc(
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
@@ -49,7 +48,7 @@ void main() {
|
||||
(tester) async {
|
||||
const messageSearchBlocKey = Key('messageSearchBloc');
|
||||
const childKey = Key('child');
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
const messageSearchBloc = MessageSearchBloc(
|
||||
key: messageSearchBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -101,7 +100,7 @@ void main() {
|
||||
(tester) async {
|
||||
const messageSearchBlocKey = Key('messageSearchBloc');
|
||||
const childKey = Key('child');
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
const messageSearchBloc = MessageSearchBloc(
|
||||
key: messageSearchBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -151,7 +150,7 @@ void main() {
|
||||
(tester) async {
|
||||
const messageSearchBlocKey = Key('messageSearchBloc');
|
||||
const childKey = Key('child');
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
const messageSearchBloc = MessageSearchBloc(
|
||||
key: messageSearchBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -243,7 +242,7 @@ void main() {
|
||||
(tester) async {
|
||||
const messageSearchBlocKey = Key('messageSearchBloc');
|
||||
const childKey = Key('child');
|
||||
final messageSearchBloc = MessageSearchBloc(
|
||||
const messageSearchBloc = MessageSearchBloc(
|
||||
key: messageSearchBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
|
||||
final testFilter = Filter.custom(operator: '\$test', value: 'testValue');
|
||||
const testFilter = Filter.custom(operator: '\$test', value: 'testValue');
|
||||
|
||||
void main() {
|
||||
List<GetMessageResponse> _generateMessages({
|
||||
@@ -56,10 +56,10 @@ void main() {
|
||||
const messageSearchListCoreKey = Key('messageSearchListCore');
|
||||
final messageSearchListCore = MessageSearchListCore(
|
||||
key: messageSearchListCoreKey,
|
||||
childBuilder: (List<GetMessageResponse> messages) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object? error) => Offstage(),
|
||||
childBuilder: (List<GetMessageResponse> messages) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object? error) => const Offstage(),
|
||||
filters: testFilter,
|
||||
);
|
||||
|
||||
@@ -86,10 +86,10 @@ void main() {
|
||||
final controller = MessageSearchListController();
|
||||
final messageSearchListCore = MessageSearchListCore(
|
||||
key: messageSearchListCoreKey,
|
||||
childBuilder: (List<GetMessageResponse> messages) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
childBuilder: (List<GetMessageResponse> messages) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
messageSearchListController: controller,
|
||||
filters: testFilter,
|
||||
);
|
||||
@@ -122,10 +122,10 @@ void main() {
|
||||
const errorWidgetKey = Key('errorWidget');
|
||||
final messageSearchListCore = MessageSearchListCore(
|
||||
key: messageSearchListCoreKey,
|
||||
childBuilder: (List<GetMessageResponse> messages) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(
|
||||
childBuilder: (List<GetMessageResponse> messages) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(
|
||||
key: errorWidgetKey,
|
||||
),
|
||||
filters: testFilter,
|
||||
@@ -173,10 +173,11 @@ void main() {
|
||||
const emptyWidgetKey = Key('emptyWidget');
|
||||
final messageSearchListCore = MessageSearchListCore(
|
||||
key: messageSearchListCoreKey,
|
||||
childBuilder: (List<GetMessageResponse> messages) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
childBuilder: (List<GetMessageResponse> messages) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) =>
|
||||
const Offstage(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
filters: testFilter,
|
||||
);
|
||||
|
||||
@@ -223,12 +224,12 @@ void main() {
|
||||
const childWidgetKey = Key('childWidget');
|
||||
final messageSearchListCore = MessageSearchListCore(
|
||||
key: messageSearchListCoreKey,
|
||||
childBuilder: (List<GetMessageResponse> messages) => Offstage(
|
||||
childBuilder: (List<GetMessageResponse> messages) => const Offstage(
|
||||
key: childWidgetKey,
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
filters: testFilter,
|
||||
);
|
||||
|
||||
@@ -283,9 +284,9 @@ void main() {
|
||||
messages.map((e) => '${e.channel?.cid}-${e.message.id}').join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
paginationParams: pagination,
|
||||
filters: testFilter,
|
||||
);
|
||||
@@ -399,9 +400,10 @@ void main() {
|
||||
.join(','),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) =>
|
||||
const Offstage(),
|
||||
paginationParams: pagination.copyWith(limit: limit),
|
||||
filters: testFilter,
|
||||
);
|
||||
|
||||
@@ -27,10 +27,9 @@ void main() {
|
||||
type: 'testType',
|
||||
user: users[index],
|
||||
createdAt: DateTime.now(),
|
||||
shadowed: false,
|
||||
replyCount: index,
|
||||
updatedAt: DateTime.now(),
|
||||
extraData: {'extra_test_field': 'extraTestData'},
|
||||
extraData: const {'extra_test_field': 'extraTestData'},
|
||||
text: 'Dummy text #$index',
|
||||
pinned: true,
|
||||
pinnedAt: DateTime.now(),
|
||||
@@ -48,10 +47,9 @@ void main() {
|
||||
user: users[index],
|
||||
parentId: messages[0].id,
|
||||
createdAt: DateTime.now(),
|
||||
shadowed: false,
|
||||
replyCount: index,
|
||||
updatedAt: DateTime.now(),
|
||||
extraData: {'extra_test_field': 'extraTestData'},
|
||||
extraData: const {'extra_test_field': 'extraTestData'},
|
||||
text: 'Dummy text #$index',
|
||||
pinned: true,
|
||||
pinnedAt: DateTime.now(),
|
||||
@@ -72,7 +70,7 @@ void main() {
|
||||
final streamChannel = StreamChannel(
|
||||
key: streamChannelKey,
|
||||
channel: mockChannel,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChannel);
|
||||
@@ -91,10 +89,10 @@ void main() {
|
||||
final streamChannel = StreamChannel(
|
||||
key: streamChannelKey,
|
||||
channel: mockChannel,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
final errorMessage = 'Error! Error! Error!';
|
||||
const errorMessage = 'Error! Error! Error!';
|
||||
final error = DioError(
|
||||
type: DioErrorType.response,
|
||||
error: errorMessage,
|
||||
@@ -128,8 +126,7 @@ void main() {
|
||||
final streamChannel = StreamChannel(
|
||||
key: streamChannelKey,
|
||||
channel: mockChannel,
|
||||
child: Offstage(key: childKey),
|
||||
showLoading: true,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
when(() => mockChannel.initialized).thenAnswer((_) async => false);
|
||||
@@ -158,8 +155,8 @@ void main() {
|
||||
final streamChannel = StreamChannel(
|
||||
key: streamChannelKey,
|
||||
channel: mockChannel,
|
||||
child: Offstage(key: childKey),
|
||||
initialMessageId: 'testInitialMessageId',
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
when(() => mockChannel.initialized).thenAnswer((_) async => true);
|
||||
@@ -213,8 +210,8 @@ void main() {
|
||||
StreamChannel(
|
||||
key: streamChannelKey,
|
||||
channel: mockChannel,
|
||||
child: Offstage(key: childKey),
|
||||
initialMessageId: initialMessageId,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
final beforePagination = PaginationParams(
|
||||
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -71,7 +71,8 @@ void main() {
|
||||
expect(find.byKey(streamChatCoreKey), findsOneWidget);
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async {
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -79,9 +80,10 @@ void main() {
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
verify(() => mockClient.closeConnection()).called(1);
|
||||
verify(mockClient.closeConnection).called(1);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -93,16 +95,16 @@ void main() {
|
||||
await tester.runAsync(() async {
|
||||
final mockClient = MockClient();
|
||||
final mockOnBackgroundEventReceived = MockOnBackgroundEventReceived();
|
||||
const backgroundKeepAlive = const Duration(seconds: 3);
|
||||
const backgroundKeepAlive = Duration(seconds: 3);
|
||||
const streamChatCoreKey = Key('streamChatCore');
|
||||
const childKey = Key('child');
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
onBackgroundEventReceived: mockOnBackgroundEventReceived,
|
||||
backgroundKeepAlive: backgroundKeepAlive,
|
||||
connectivityStream: Stream.value(ConnectivityResult.mobile),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -111,8 +113,9 @@ void main() {
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final event = Event(type: EventType.any);
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async {
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -120,6 +123,7 @@ void main() {
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
@@ -129,7 +133,7 @@ void main() {
|
||||
|
||||
await Future.delayed(backgroundKeepAlive);
|
||||
|
||||
verify(() => mockClient.closeConnection()).called(1);
|
||||
verify(mockClient.closeConnection).called(1);
|
||||
verifyNever(() => mockOnBackgroundEventReceived.call(event));
|
||||
});
|
||||
},
|
||||
@@ -143,15 +147,15 @@ void main() {
|
||||
await tester.runAsync(() async {
|
||||
final mockClient = MockClient();
|
||||
final mockOnBackgroundEventReceived = MockOnBackgroundEventReceived();
|
||||
const backgroundKeepAlive = const Duration(seconds: 3);
|
||||
const backgroundKeepAlive = Duration(seconds: 3);
|
||||
const streamChatCoreKey = Key('streamChatCore');
|
||||
const childKey = Key('child');
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
onBackgroundEventReceived: mockOnBackgroundEventReceived,
|
||||
backgroundKeepAlive: backgroundKeepAlive,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -160,12 +164,13 @@ void main() {
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final event = Event(type: EventType.any);
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
|
||||
final streamChatCoreState = tester.state<StreamChatCoreState>(
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
@@ -193,8 +198,8 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
connectivityStream: Stream.value(ConnectivityResult.mobile),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -203,10 +208,14 @@ void main() {
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final event = Event(type: EventType.any);
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.openConnection())
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.openConnection)
|
||||
.thenAnswer((_) async => OwnUser(id: 'test'));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
@@ -214,6 +223,7 @@ void main() {
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
@@ -222,7 +232,7 @@ void main() {
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.resumed);
|
||||
|
||||
verify(() => mockClient.openConnection()).called(1);
|
||||
verify(mockClient.openConnection).called(1);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -238,18 +248,22 @@ void main() {
|
||||
const childKey = Key('child');
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.openConnection())
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.openConnection)
|
||||
.thenAnswer((_) async => OwnUser(id: 'test'));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
connectivityStream: Stream.value(ConnectivityResult.none),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -261,6 +275,7 @@ void main() {
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
@@ -269,7 +284,7 @@ void main() {
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.resumed);
|
||||
|
||||
verifyNever(() => mockClient.openConnection());
|
||||
verifyNever(mockClient.openConnection);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -287,7 +302,7 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -310,9 +325,7 @@ void main() {
|
||||
emits(ownUser),
|
||||
);
|
||||
|
||||
addTearDown(() {
|
||||
userController.close();
|
||||
});
|
||||
addTearDown(userController.close);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -328,18 +341,22 @@ void main() {
|
||||
BehaviorSubject.seeded(ConnectivityResult.none);
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.openConnection())
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.openConnection)
|
||||
.thenAnswer((_) async => OwnUser(id: 'test'));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
connectivityStream: _connectivityController.stream,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -351,7 +368,9 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verify(() => mockClient.openConnection()).called(1);
|
||||
verify(mockClient.openConnection).called(1);
|
||||
|
||||
addTearDown(_connectivityController.close);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -368,8 +387,8 @@ void main() {
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
connectivityStream: _connectivityController.stream,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -378,10 +397,14 @@ void main() {
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.openConnection())
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.openConnection)
|
||||
.thenAnswer((_) async => OwnUser(id: 'test'));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.connected);
|
||||
|
||||
@@ -389,7 +412,9 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verify(() => mockClient.closeConnection()).called(1);
|
||||
verify(mockClient.closeConnection).called(1);
|
||||
|
||||
addTearDown(_connectivityController.close);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -405,18 +430,22 @@ void main() {
|
||||
BehaviorSubject.seeded(ConnectivityResult.none);
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.openConnection())
|
||||
when(mockClient.on).thenAnswer((_) => Stream.value(event));
|
||||
when(mockClient.openConnection)
|
||||
.thenAnswer((_) async => OwnUser(id: 'test'));
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
when(mockClient.closeConnection).thenAnswer((_) async {
|
||||
return;
|
||||
});
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
final streamChatCore = StreamChatCore(
|
||||
key: streamChatCoreKey,
|
||||
client: mockClient,
|
||||
child: Offstage(key: childKey),
|
||||
connectivityStream: _connectivityController.stream,
|
||||
child: const Offstage(key: childKey),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(streamChatCore);
|
||||
@@ -428,6 +457,7 @@ void main() {
|
||||
find.byKey(streamChatCoreKey),
|
||||
);
|
||||
|
||||
// ignore: cascade_invocations
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.paused);
|
||||
|
||||
@@ -437,7 +467,9 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verifyNever(() => mockClient.closeConnection());
|
||||
verifyNever(mockClient.closeConnection);
|
||||
|
||||
addTearDown(_connectivityController.close);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -12,26 +12,24 @@ void main() {
|
||||
List<User> _generateUsers({
|
||||
int count = 3,
|
||||
int offset = 0,
|
||||
}) {
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return User(
|
||||
id: 'testId$index',
|
||||
role: 'testRole$index',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
lastActive: DateTime.now(),
|
||||
online: true,
|
||||
banned: false,
|
||||
extraData: {
|
||||
'name': '${alphabets[index]}-testName',
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return User(
|
||||
id: 'testId$index',
|
||||
role: 'testRole$index',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
lastActive: DateTime.now(),
|
||||
online: true,
|
||||
extraData: {
|
||||
'name': '${alphabets[index]}-testName',
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should throw if UserListCore is used where UsersBloc is not present '
|
||||
@@ -40,10 +38,10 @@ void main() {
|
||||
const userListCoreKey = Key('userListCore');
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(userListCore);
|
||||
@@ -59,10 +57,10 @@ void main() {
|
||||
const userListCoreKey = Key('userListCore');
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
@@ -88,10 +86,10 @@ void main() {
|
||||
final controller = UserListController();
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
userListController: controller,
|
||||
);
|
||||
|
||||
@@ -122,9 +120,9 @@ void main() {
|
||||
const errorWidgetKey = Key('errorWidget');
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) =>
|
||||
Container(key: errorWidgetKey),
|
||||
);
|
||||
@@ -168,10 +166,10 @@ void main() {
|
||||
const emptyWidgetKey = Key('emptyWidget');
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
listBuilder: (_, __) => const Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Container(key: emptyWidgetKey),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
@@ -214,9 +212,9 @@ void main() {
|
||||
final userListCore = UserListCore(
|
||||
key: userListCoreKey,
|
||||
listBuilder: (_, __) => Container(key: listWidgetKey),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
);
|
||||
|
||||
final mockClient = MockClient();
|
||||
@@ -261,20 +259,20 @@ void main() {
|
||||
listBuilder: (_, items) => Container(
|
||||
key: listWidgetKey,
|
||||
child: ListView(
|
||||
children: items.map((e) {
|
||||
return Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
);
|
||||
}).toList(growable: false),
|
||||
children: items
|
||||
.map((e) => Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
groupAlphabetically: true,
|
||||
);
|
||||
|
||||
@@ -329,20 +327,20 @@ void main() {
|
||||
listBuilder: (_, items) => Container(
|
||||
key: listWidgetKey,
|
||||
child: ListView(
|
||||
children: items.map((e) {
|
||||
return Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
);
|
||||
}).toList(growable: false),
|
||||
children: items
|
||||
.map((e) => Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => const Offstage(),
|
||||
pagination: pagination,
|
||||
groupAlphabetically: true,
|
||||
);
|
||||
@@ -425,7 +423,7 @@ void main() {
|
||||
const pagination = PaginationParams();
|
||||
|
||||
StateSetter? _stateSetter;
|
||||
int limit = pagination.limit;
|
||||
var limit = pagination.limit;
|
||||
|
||||
const userListCoreKey = Key('userListCore');
|
||||
const listWidgetKey = Key('listWidget');
|
||||
@@ -434,20 +432,21 @@ void main() {
|
||||
listBuilder: (_, items) => Container(
|
||||
key: listWidgetKey,
|
||||
child: ListView(
|
||||
children: items.map((e) {
|
||||
return Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
);
|
||||
}).toList(growable: false),
|
||||
children: items
|
||||
.map((e) => Container(
|
||||
key: Key(e.key ?? ''),
|
||||
child: e.when(
|
||||
headerItem: (heading) => Text(heading),
|
||||
userItem: (user) => Text(user.id),
|
||||
),
|
||||
))
|
||||
.toList(growable: false),
|
||||
),
|
||||
),
|
||||
loadingBuilder: (BuildContext context) => Offstage(),
|
||||
emptyBuilder: (BuildContext context) => Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) => Offstage(),
|
||||
loadingBuilder: (BuildContext context) => const Offstage(),
|
||||
emptyBuilder: (BuildContext context) => const Offstage(),
|
||||
errorBuilder: (BuildContext context, Object error) =>
|
||||
const Offstage(),
|
||||
pagination: pagination.copyWith(limit: limit),
|
||||
groupAlphabetically: true,
|
||||
);
|
||||
|
||||
@@ -12,30 +12,28 @@ void main() {
|
||||
List<User> _generateUsers({
|
||||
int count = 3,
|
||||
int offset = 0,
|
||||
}) {
|
||||
return List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return User(
|
||||
id: 'testId$index',
|
||||
role: 'testRole$index',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
lastActive: DateTime.now(),
|
||||
online: true,
|
||||
banned: false,
|
||||
extraData: {'extra_data_key': 'extraDataValue'},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
List.generate(
|
||||
count,
|
||||
(index) {
|
||||
index = index + offset;
|
||||
return User(
|
||||
id: 'testId$index',
|
||||
role: 'testRole$index',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
lastActive: DateTime.now(),
|
||||
online: true,
|
||||
extraData: const {'extra_data_key': 'extraDataValue'},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'usersBlocState.queryUsers() should throw if used where '
|
||||
'StreamChat is not present in the widget tree',
|
||||
(tester) async {
|
||||
final usersBloc = UsersBloc(
|
||||
const usersBloc = UsersBloc(
|
||||
child: Offstage(),
|
||||
);
|
||||
|
||||
@@ -49,7 +47,7 @@ void main() {
|
||||
(tester) async {
|
||||
const usersBlocKey = Key('usersBloc');
|
||||
const childKey = Key('child');
|
||||
final usersBloc = UsersBloc(
|
||||
const usersBloc = UsersBloc(
|
||||
key: usersBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -98,7 +96,7 @@ void main() {
|
||||
(tester) async {
|
||||
const usersBlocKey = Key('usersBloc');
|
||||
const childKey = Key('child');
|
||||
final usersBloc = UsersBloc(
|
||||
const usersBloc = UsersBloc(
|
||||
key: usersBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -116,7 +114,7 @@ void main() {
|
||||
find.byKey(usersBlocKey),
|
||||
);
|
||||
|
||||
final error = 'Error! Error! Error!';
|
||||
const error = 'Error! Error! Error!';
|
||||
|
||||
when(() => mockClient.queryUsers(
|
||||
filter: any(named: 'filter'),
|
||||
@@ -148,7 +146,7 @@ void main() {
|
||||
(tester) async {
|
||||
const usersBlocKey = Key('usersBloc');
|
||||
const childKey = Key('child');
|
||||
final usersBloc = UsersBloc(
|
||||
const usersBloc = UsersBloc(
|
||||
key: usersBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -231,7 +229,7 @@ void main() {
|
||||
(tester) async {
|
||||
const usersBlocKey = Key('usersBloc');
|
||||
const childKey = Key('child');
|
||||
final usersBloc = UsersBloc(
|
||||
const usersBloc = UsersBloc(
|
||||
key: usersBlocKey,
|
||||
child: Offstage(key: childKey),
|
||||
);
|
||||
@@ -275,7 +273,7 @@ void main() {
|
||||
final offset = users.length;
|
||||
final pagination = PaginationParams(offset: offset);
|
||||
|
||||
final error = 'Error! Error! Error!';
|
||||
const error = 'Error! Error! Error!';
|
||||
|
||||
when(() => mockClient.queryUsers(
|
||||
filter: any(named: 'filter'),
|
||||
|
||||
Reference in New Issue
Block a user