-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): be lenient when calling nullable onThreadTap method (#1854)
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/stream_chat_flutter/test/src/message_list_view/bottom_row_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:stream_chat_flutter/src/message_widget/bottom_row.dart'; | ||
import 'package:stream_chat_flutter/stream_chat_flutter.dart'; | ||
|
||
import '../mocks.dart'; | ||
|
||
void main() { | ||
late Channel channel; | ||
late ChannelClientState channelClientState; | ||
|
||
setUp(() { | ||
channel = MockChannel(); | ||
when(() => channel.on(any(), any(), any(), any())) | ||
.thenAnswer((_) => const Stream.empty()); | ||
channelClientState = MockChannelState(); | ||
when(() => channel.state).thenReturn(channelClientState); | ||
when(() => channelClientState.messages).thenReturn([ | ||
Message( | ||
id: 'parentId', | ||
) | ||
]); | ||
}); | ||
|
||
setUpAll(() { | ||
registerFallbackValue(Message()); | ||
}); | ||
|
||
testWidgets('BottomRow', (tester) async { | ||
final theme = StreamChatThemeData.light(); | ||
final onThreadTap = MockVoidSingleParamCallback<Message>(); | ||
|
||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Scaffold( | ||
body: Center( | ||
child: StreamChannel( | ||
channel: channel, | ||
child: BottomRow( | ||
message: Message( | ||
parentId: 'parentId', | ||
), | ||
isDeleted: false, | ||
showThreadReplyIndicator: false, | ||
showUsername: false, | ||
showInChannel: true, | ||
showTimeStamp: false, | ||
reverse: false, | ||
showSendingIndicator: false, | ||
hasUrlAttachments: false, | ||
isGiphy: false, | ||
isOnlyEmoji: false, | ||
messageTheme: theme.otherMessageTheme, | ||
streamChatTheme: theme, | ||
hasNonUrlAttachments: false, | ||
streamChat: StreamChatState(), | ||
onThreadTap: onThreadTap, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(GestureDetector)); | ||
await tester.pumpAndSettle(); | ||
|
||
verify(() => onThreadTap.call(any())); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters