Files
stream-chat-flutter/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart
T
Reuben TurnerandGitHub b306978da6 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
2021-07-16 10:49:51 +02:00

245 lines
7.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'mocks.dart';
import 'simple_frame.dart';
void main() {
testGoldens(
'it should show no reactions',
(WidgetTester tester) async {
await tester.pumpWidgetBuilder(
SimpleFrame(
child: StreamChatTheme(
data: StreamChatThemeData(),
child: const SizedBox(
child: ReactionBubble(
reactions: [],
borderColor: Colors.black,
backgroundColor: Colors.white,
maskColor: Colors.white,
),
),
),
),
surfaceSize: const Size(100, 100),
);
await screenMatchesGolden(tester, 'reaction_bubble_0');
},
);
testGoldens(
'it should show a like - light theme',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final themeData = ThemeData.light();
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
final theme = StreamChatThemeData.fromTheme(themeData);
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
streamChatThemeData: theme,
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: SizedBox(
child: ReactionBubble(
reactions: [
Reaction(
type: 'like',
user: User(id: 'test'),
),
],
borderColor: theme.ownMessageTheme.reactionsBorderColor!,
backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!,
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
),
surfaceSize: const Size(100, 100),
);
await screenMatchesGolden(tester, 'reaction_bubble_like_light');
},
);
testGoldens(
'it should show a like - dark theme',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final themeData = ThemeData.dark();
final theme = StreamChatThemeData.fromTheme(themeData);
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: Container(
color: Colors.black,
child: ReactionBubble(
reactions: [
Reaction(
type: 'like',
user: User(id: 'test'),
),
],
borderColor: theme.ownMessageTheme.reactionsBorderColor!,
backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!,
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
),
surfaceSize: const Size(100, 100),
);
await screenMatchesGolden(tester, 'reaction_bubble_like_dark');
},
);
testGoldens(
'it should show three reactions - light theme',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final themeData = ThemeData.light();
final theme = StreamChatThemeData.fromTheme(themeData);
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: Container(
color: Colors.black,
child: ReactionBubble(
reactions: [
Reaction(
type: 'like',
user: User(id: 'test'),
),
Reaction(
type: 'like',
user: User(id: 'user-id'),
),
Reaction(
type: 'like',
user: User(id: 'test'),
),
],
borderColor: theme.ownMessageTheme.reactionsBorderColor!,
backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!,
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
),
surfaceSize: const Size(140, 140),
);
await screenMatchesGolden(tester, 'reaction_bubble_3_light');
},
);
testGoldens(
'it should show three reactions - dark theme',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final themeData = ThemeData.dark();
final theme = StreamChatThemeData.fromTheme(themeData);
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
connectivityStream: Stream.value(ConnectivityResult.mobile),
child: Container(
color: Colors.black,
child: ReactionBubble(
reactions: [
Reaction(
type: 'like',
user: User(id: 'test'),
),
Reaction(
type: 'like',
user: User(id: 'user-id'),
),
Reaction(
type: 'like',
user: User(id: 'test'),
),
],
borderColor: theme.ownMessageTheme.reactionsBorderColor!,
backgroundColor: theme.ownMessageTheme.reactionsBackgroundColor!,
maskColor: theme.ownMessageTheme.reactionsMaskColor!,
),
),
),
surfaceSize: const Size(140, 140),
);
await screenMatchesGolden(tester, 'reaction_bubble_3_dark');
},
);
testGoldens(
'it should show two reactions with customized ui',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final themeData = ThemeData();
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
await tester.pumpWidgetBuilder(
StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
streamChatThemeData: StreamChatThemeData.fromTheme(themeData),
child: SizedBox(
child: ReactionBubble(
reactions: [
Reaction(
type: 'like',
user: User(id: 'test'),
),
Reaction(
type: 'love',
user: User(id: 'user-id'),
),
Reaction(
type: 'unknown',
user: User(id: 'test'),
),
],
borderColor: Colors.red,
backgroundColor: Colors.blue,
maskColor: Colors.green,
reverse: true,
flipTail: true,
tailCirclesSpacing: 4,
),
),
),
surfaceSize: const Size(200, 200),
);
await screenMatchesGolden(tester, 'reaction_bubble_2');
},
);
}