lint test

This commit is contained in:
Deven Joshi
2021-05-05 17:58:50 +05:30
parent ad86cf0cd6
commit f5daa8f49c
14 changed files with 129 additions and 166 deletions
@@ -128,7 +128,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: AttachmentActionsModal(
message: Message(
text: 'test',
@@ -185,7 +185,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: AttachmentActionsModal(
message: message,
currentIndex: 0,
@@ -218,7 +218,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: AttachmentActionsModal(
onShowMessage: onShowMessage,
message: Message(
@@ -250,9 +250,8 @@ void main() {
final clientState = MockClientState();
final mockChannel = MockChannel();
when(() => mockChannel.updateMessage(any())).thenAnswer((_) async {
return UpdateMessageResponse();
});
when(() => mockChannel.updateMessage(any()))
.thenAnswer((_) async => UpdateMessageResponse());
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
@@ -275,12 +274,10 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
client: client,
child: child!,
);
},
builder: (context, child) => StreamChat(
client: client,
child: child,
),
home: StreamChannel(
showLoading: false,
channel: mockChannel,
@@ -307,9 +304,8 @@ void main() {
final clientState = MockClientState();
final mockChannel = MockChannel();
when(() => mockChannel.updateMessage(any())).thenAnswer((_) async {
return UpdateMessageResponse();
});
when(() => mockChannel.updateMessage(any()))
.thenAnswer((_) async => UpdateMessageResponse());
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
@@ -328,12 +324,10 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
client: client,
child: child!,
);
},
builder: (context, child) => StreamChat(
client: client,
child: child,
),
home: StreamChannel(
showLoading: false,
channel: mockChannel,
@@ -352,15 +346,15 @@ void main() {
);
testWidgets(
// ignore: lines_longer_than_80_chars
'tapping on delete in chat should remove the message if that\'s the only attachment and there is no text',
(WidgetTester tester) async {
final client = MockClient();
final clientState = MockClientState();
final mockChannel = MockChannel();
when(() => mockChannel.deleteMessage(any())).thenAnswer((_) async {
return EmptyResponse();
});
when(() => mockChannel.deleteMessage(any()))
.thenAnswer((_) async => EmptyResponse());
when(() => client.state).thenReturn(clientState);
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
@@ -378,12 +372,10 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
child: child!,
);
},
child: child,
),
home: StreamChannel(
showLoading: false,
channel: mockChannel,
@@ -412,13 +404,11 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
child: child!,
);
},
home: Container(
child: child,
),
home: SizedBox(
child: AttachmentActionsModal(
imageDownloader: imageDownloader,
message: Message(
@@ -451,8 +441,8 @@ void main() {
imageDownloader.progressCallback!(100, 100);
imageDownloader.completer.complete('path');
await tester.pump();
expect(find.byKey(Key('completedIcon')), findsOneWidget);
await tester.pumpAndSettle(Duration(milliseconds: 500));
expect(find.byKey(const Key('completedIcon')), findsOneWidget);
await tester.pumpAndSettle(const Duration(milliseconds: 500));
},
);
@@ -469,12 +459,10 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
child: child!,
);
},
),
home: Container(
child: AttachmentActionsModal(
fileDownloader: fileDownloader,
@@ -508,8 +496,8 @@ void main() {
fileDownloader.progressCallback!(100, 100);
fileDownloader.completer.complete('path');
await tester.pump();
expect(find.byKey(Key('completedIcon')), findsOneWidget);
await tester.pumpAndSettle(Duration(milliseconds: 500));
expect(find.byKey(const Key('completedIcon')), findsOneWidget);
await tester.pumpAndSettle(const Duration(milliseconds: 500));
},
);
}
@@ -23,9 +23,9 @@ void main() {
data: streamTheme,
child: StreamChannel(
channel: channel,
child: Container(
child: SizedBox(
child: FileAttachment(
size: Size(
size: const Size(
300,
300,
),
@@ -33,7 +33,7 @@ void main() {
attachment: Attachment(
type: 'file',
title: 'example.pdf',
extraData: {
extraData: const {
'mime_type': 'pdf',
},
),
@@ -15,16 +15,14 @@ void main() {
MaterialApp(
home: const Material(child: Text('Home')),
routes: <String, WidgetBuilder>{
'/next': (BuildContext context) {
return Material(
'/next': (BuildContext context) => Material(
child: Center(
child: StreamChatTheme(
data: StreamChatThemeData.fromTheme(theme),
child: StreamBackButton(),
),
),
);
},
),
},
),
);
@@ -52,7 +50,7 @@ void main() {
child: Center(
child: StreamChatTheme(
data: StreamChatThemeData.fromTheme(theme),
child: StreamBackButton(),
child: const StreamBackButton(),
),
),
),
@@ -78,8 +76,7 @@ void main() {
MaterialApp(
home: const Material(child: Text('Home')),
routes: <String, WidgetBuilder>{
'/next': (BuildContext context) {
return Material(
'/next': (BuildContext context) => Material(
child: Center(
child: StreamChatTheme(
data: StreamChatThemeData.fromTheme(theme),
@@ -88,8 +85,7 @@ void main() {
),
),
),
);
},
),
},
),
);
@@ -131,7 +127,7 @@ void main() {
child: Center(
child: StreamChat(
client: client,
child: StreamBackButton(
child: const StreamBackButton(
showUnreads: true,
),
),
@@ -54,7 +54,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelHeader(),
),
),
@@ -115,7 +115,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelHeader(
showConnectionStateTile: true,
),
@@ -178,7 +178,7 @@ void main() {
child: StreamChannel(
channel: channel,
showLoading: false,
child: Scaffold(
child: const Scaffold(
body: ChannelHeader(
showConnectionStateTile: true,
),
@@ -242,7 +242,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelHeader(
leading: Text('leading'),
subtitle: Text('subtitle'),
@@ -314,7 +314,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelHeader(
showTypingIndicator: false,
showBackButton: false,
@@ -34,7 +34,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelImage(),
),
),
@@ -112,7 +112,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelImage(),
),
),
@@ -207,7 +207,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelImage(),
),
),
@@ -248,7 +248,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelImage(
selected: true,
),
@@ -257,7 +257,7 @@ void main() {
),
));
expect(find.byKey(Key('selectedImage')), findsOneWidget);
expect(find.byKey(const Key('selectedImage')), findsOneWidget);
},
);
}
@@ -21,7 +21,7 @@ void main() {
MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: ChannelListHeader(),
),
),
@@ -51,7 +51,7 @@ void main() {
MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: ChannelListHeader(
showConnectionStateTile: true,
),
@@ -80,7 +80,7 @@ void main() {
MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: ChannelListHeader(
showConnectionStateTile: true,
),
@@ -111,12 +111,10 @@ void main() {
client: client,
child: Scaffold(
body: ChannelListHeader(
titleBuilder: (context, status, client) {
return Text('TITLE');
},
subtitle: Text('SUBTITLE'),
leading: Text('LEADING'),
actions: [
titleBuilder: (context, status, client) => const Text('TITLE'),
subtitle: const Text('SUBTITLE'),
leading: const Text('LEADING'),
actions: const [
Text('ACTION'),
],
client: client,
@@ -61,7 +61,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: ChannelName(),
),
),
@@ -19,7 +19,7 @@ void main() {
await tester.pumpWidget(MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: DeletedMessage(
messageTheme: MessageTheme(
createdAt: TextStyle(
@@ -81,7 +81,7 @@ void main() {
),
),
),
surfaceSize: Size.square(200),
surfaceSize: const Size.square(200),
);
await screenMatchesGolden(tester, 'deleted_message_light');
@@ -133,7 +133,7 @@ void main() {
),
),
),
surfaceSize: Size.square(200),
surfaceSize: const Size.square(200),
);
await screenMatchesGolden(tester, 'deleted_message_dark');
@@ -189,7 +189,7 @@ void main() {
),
),
),
surfaceSize: Size.square(200),
surfaceSize: const Size.square(200),
);
await screenMatchesGolden(tester, 'deleted_message_custom');
@@ -19,9 +19,9 @@ void main() {
await tester.pumpWidget(MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: Portal(
child: Container(
child: SizedBox(
child: InfoTile(
showMessage: true,
message: 'message',
@@ -49,9 +49,9 @@ void main() {
await tester.pumpWidget(MaterialApp(
home: StreamChat(
client: client,
child: Scaffold(
child: const Scaffold(
body: Portal(
child: Container(
child: SizedBox(
child: InfoTile(
showMessage: false,
message: 'message',
@@ -8,7 +8,8 @@ import 'mocks.dart';
void main() {
setUpAll(() {
registerFallbackValue(MaterialPageRoute(builder: (context) => SizedBox()));
registerFallbackValue(
MaterialPageRoute(builder: (context) => const SizedBox()));
registerFallbackValue(Message());
});
@@ -29,7 +30,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
text: 'test',
@@ -45,7 +46,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.byKey(Key('MessageWidget')), findsOneWidget);
expect(find.byKey(const Key('MessageWidget')), findsOneWidget);
expect(find.text('Thread Reply'), findsOneWidget);
expect(find.text('Reply'), findsOneWidget);
expect(find.text('Edit Message'), findsOneWidget);
@@ -71,7 +72,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: MessageActionsModal(
showEditMessage: false,
showCopyMessage: false,
@@ -92,7 +93,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.byKey(Key('MessageWidget')), findsOneWidget);
expect(find.byKey(const Key('MessageWidget')), findsOneWidget);
expect(find.text('Reply'), findsNothing);
expect(find.text('Thread reply'), findsNothing);
expect(find.text('Edit message'), findsNothing);
@@ -120,7 +121,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
text: 'test',
@@ -131,8 +132,8 @@ void main() {
messageTheme: streamTheme.ownMessageTheme,
customActions: [
MessageAction(
leading: Icon(Icons.check),
title: Text('title'),
leading: const Icon(Icons.check),
title: const Text('title'),
onTap: (m) {
tapped = true;
},
@@ -175,7 +176,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: MessageActionsModal(
onReplyTap: (m) {
tapped = true;
@@ -220,7 +221,7 @@ void main() {
home: StreamChat(
streamChatThemeData: streamTheme,
client: client,
child: Container(
child: SizedBox(
child: MessageActionsModal(
onThreadReplyTap: (m) {
tapped = true;
@@ -260,18 +261,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
text: 'test',
@@ -310,22 +309,18 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
editMessageInputBuilder: (context, m) {
return Text('test');
},
editMessageInputBuilder: (context, m) => const Text('test'),
message: Message(
text: 'test',
user: User(
@@ -365,18 +360,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
onCopyTap: (m) => tapped = true,
message: Message(
@@ -416,18 +409,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
status: MessageSendingStatus.failed,
@@ -467,18 +458,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
status: MessageSendingStatus.failed_update,
@@ -516,18 +505,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
id: 'testid',
@@ -575,18 +562,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
id: 'testid',
@@ -634,18 +619,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
id: 'testid',
@@ -689,18 +672,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
id: 'testid',
@@ -748,18 +729,16 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) {
return StreamChat(
builder: (context, child) => StreamChat(
client: client,
streamChatThemeData: streamTheme,
child: child!,
);
},
child: child,
),
theme: themeData,
home: StreamChannel(
showLoading: false,
channel: channel,
child: Container(
child: SizedBox(
child: MessageActionsModal(
message: Message(
id: 'testid',
@@ -67,7 +67,7 @@ void main() {
client: client,
child: StreamChannel(
channel: channel,
child: Scaffold(
child: const Scaffold(
body: MessageInput(),
),
),
@@ -76,7 +76,7 @@ void main() {
expect(find.byType(TextField), findsOneWidget);
expect(find.byType(StreamSvgIcon), findsNWidgets(8));
expect(find.byKey(Key('messageInputText')), findsOneWidget);
expect(find.byKey(const Key('messageInputText')), findsOneWidget);
},
);
}
@@ -41,7 +41,7 @@ void main() {
),
);
await tester.pump(Duration(milliseconds: 1000));
await tester.pump(const Duration(milliseconds: 1000));
expect(find.byType(MessageWidget), findsOneWidget);
final messageWidget =
@@ -95,6 +95,7 @@ void main() {
],
);
// ignore: prefer_function_declarations_over_variables
final onUserAvatarTap = (u) => print('ok');
await tester.pumpWidget(
@@ -109,16 +110,16 @@ void main() {
showUserAvatar: DisplayWidget.gone,
reverse: true,
attachmentBorderRadiusGeometry: BorderRadius.circular(1),
attachmentShape: RoundedRectangleBorder(),
attachmentShape: const RoundedRectangleBorder(),
showReactions: false,
messageShape: RoundedRectangleBorder(),
messageShape: const RoundedRectangleBorder(),
onUserAvatarTap: onUserAvatarTap,
),
),
),
);
await tester.pump(Duration(milliseconds: 1000));
await tester.pump(const Duration(milliseconds: 1000));
expect(find.byType(MessageWidget), findsOneWidget);
final messageWidget =
@@ -130,8 +131,8 @@ void main() {
expect(messageWidget.showUserAvatar, DisplayWidget.gone);
expect(messageWidget.reverse, true);
expect(messageWidget.showReactions, false);
expect(messageWidget.attachmentShape, RoundedRectangleBorder());
expect(messageWidget.shape, RoundedRectangleBorder());
expect(messageWidget.attachmentShape, const RoundedRectangleBorder());
expect(messageWidget.shape, const RoundedRectangleBorder());
expect(messageWidget.showReactions, false);
expect(messageWidget.showUsername, false);
expect(messageWidget.showThreadReplyIndicator, false);
@@ -11,6 +11,7 @@ class MockChannel extends Mock implements Channel {
Future<bool> get initialized async => true;
@override
// ignore: prefer_expression_function_bodies
Future<void> keyStroke([String? parentId]) async {
return;
}
@@ -16,7 +16,7 @@ void main() {
SimpleFrame(
child: StreamChatTheme(
data: StreamChatThemeData(),
child: Container(
child: const SizedBox(
child: ReactionBubble(
reactions: [],
borderColor: Colors.black,