fix tests
This commit is contained in:
@@ -178,7 +178,7 @@ class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
client.state.totalUnreadCountStream.listen((count) {
|
client.state?.totalUnreadCountStream?.listen((count) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
FlutterAppBadger.updateBadgeCount(count);
|
FlutterAppBadger.updateBadgeCount(count);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,13 +10,21 @@ void main() {
|
|||||||
testWidgets(
|
testWidgets(
|
||||||
'it should show one thumbs from the picker',
|
'it should show one thumbs from the picker',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
|
final client = MockClient();
|
||||||
|
final clientState = MockClientState();
|
||||||
final themeData = ThemeData();
|
final themeData = ThemeData();
|
||||||
|
|
||||||
|
when(client.state).thenReturn(clientState);
|
||||||
|
when(clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||||
|
|
||||||
final streamTheme = StreamChatThemeData.getDefaultTheme(themeData);
|
final streamTheme = StreamChatThemeData.getDefaultTheme(themeData);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: themeData,
|
theme: themeData,
|
||||||
home: StreamChatTheme(
|
home: StreamChat(
|
||||||
data: streamTheme,
|
client: client,
|
||||||
|
streamChatThemeData: streamTheme,
|
||||||
child: MessageReactionsModal(
|
child: MessageReactionsModal(
|
||||||
message: Message(
|
message: Message(
|
||||||
id: 'test',
|
id: 'test',
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
|
import 'mocks.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'it should show no reactions',
|
'it should show no reactions',
|
||||||
@@ -29,17 +32,25 @@ void main() {
|
|||||||
testWidgets(
|
testWidgets(
|
||||||
'it should show a thumb up',
|
'it should show a thumb up',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
|
final client = MockClient();
|
||||||
|
final clientState = MockClientState();
|
||||||
final themeData = ThemeData();
|
final themeData = ThemeData();
|
||||||
|
|
||||||
|
when(client.state).thenReturn(clientState);
|
||||||
|
when(clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: themeData,
|
theme: themeData,
|
||||||
home: StreamChatTheme(
|
home: StreamChat(
|
||||||
data: StreamChatThemeData.getDefaultTheme(themeData),
|
client: client,
|
||||||
|
streamChatThemeData: StreamChatThemeData.getDefaultTheme(themeData),
|
||||||
child: Container(
|
child: Container(
|
||||||
child: ReactionBubble(
|
child: ReactionBubble(
|
||||||
reactions: [
|
reactions: [
|
||||||
Reaction(
|
Reaction(
|
||||||
type: 'thumbs_up',
|
type: 'thumbs_up',
|
||||||
|
user: User(id: 'test'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
borderColor: Colors.black,
|
borderColor: Colors.black,
|
||||||
@@ -56,20 +67,29 @@ void main() {
|
|||||||
testWidgets(
|
testWidgets(
|
||||||
'it should show two reactions',
|
'it should show two reactions',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
|
final client = MockClient();
|
||||||
|
final clientState = MockClientState();
|
||||||
final themeData = ThemeData();
|
final themeData = ThemeData();
|
||||||
|
|
||||||
|
when(client.state).thenReturn(clientState);
|
||||||
|
when(clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: themeData,
|
theme: themeData,
|
||||||
home: StreamChatTheme(
|
home: StreamChat(
|
||||||
data: StreamChatThemeData.getDefaultTheme(themeData),
|
client: client,
|
||||||
|
streamChatThemeData: StreamChatThemeData.getDefaultTheme(themeData),
|
||||||
child: Container(
|
child: Container(
|
||||||
child: ReactionBubble(
|
child: ReactionBubble(
|
||||||
reactions: [
|
reactions: [
|
||||||
Reaction(
|
Reaction(
|
||||||
type: 'thumbs_up',
|
type: 'thumbs_up',
|
||||||
|
user: User(id: 'test'),
|
||||||
),
|
),
|
||||||
Reaction(
|
Reaction(
|
||||||
type: 'love',
|
type: 'love',
|
||||||
|
user: User(id: 'test'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
borderColor: Colors.black,
|
borderColor: Colors.black,
|
||||||
|
|||||||
Reference in New Issue
Block a user