This repository has been archived by the owner on May 31, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See PR #124
- Loading branch information
Showing
39 changed files
with
2,150 additions
and
7 deletions.
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
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
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,9 @@ | ||
import 'package:flutter_email_sender/flutter_email_sender.dart'; | ||
|
||
/// Sends and email about a post reported | ||
class ReportPostUseCase { | ||
/// Syncs the locally stored data to the chain. | ||
Future<void> send(Email email) async { | ||
await FlutterEmailSender.send(email); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:mooncake/ui/ui.dart'; | ||
import '../../helper.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/export.dart'; | ||
import '../../../mocks/mocks.dart'; | ||
import 'package:mooncake/entities/entities.dart'; | ||
|
||
void main() { | ||
MockPostDetailsBloc mockPostDetailsBloc = MockPostDetailsBloc(); | ||
MockAccountBloc mockAccountBloc = MockAccountBloc(); | ||
MockNavigatorBloc mockNavigatorBloc = MockNavigatorBloc(); | ||
MooncakeAccount userAccount = MooncakeAccount( | ||
profilePicUri: "https://example.com/avatar.png", | ||
moniker: "john-doe", | ||
cosmosAccount: CosmosAccount( | ||
accountNumber: 153, | ||
address: "desmos1ew60ztvqxlf5kjjyyzxf7hummlwdadgesu3725", | ||
coins: [ | ||
StdCoin(amount: "10000", denom: "udaric"), | ||
], | ||
sequence: 45, | ||
), | ||
); | ||
testWidgets('PostDetailsScreen: Displays correctly', | ||
(WidgetTester tester) async { | ||
when(mockPostDetailsBloc.state).thenReturn(PostDetailsLoaded.first( | ||
user: userAccount, | ||
post: testPost, | ||
comments: testPosts, | ||
)); | ||
|
||
when(mockAccountBloc.state).thenReturn(LoggedIn.initial(userAccount)); | ||
|
||
await tester.pumpWidget( | ||
makeTestableWidget( | ||
child: MultiBlocProvider( | ||
providers: [ | ||
BlocProvider<PostDetailsBloc>( | ||
create: (_) => mockPostDetailsBloc, | ||
), | ||
BlocProvider<AccountBloc>( | ||
create: (_) => mockAccountBloc, | ||
), | ||
BlocProvider<NavigatorBloc>( | ||
create: (_) => mockNavigatorBloc, | ||
), | ||
], | ||
child: PostDetailsScreen(), | ||
), | ||
), | ||
); | ||
|
||
await tester.pumpAndSettle(); | ||
expect(find.byType(PostDetailsMainContent), findsOneWidget); | ||
}); | ||
|
||
testWidgets('PostDetailsScreen: Displays Loading correctly', | ||
(WidgetTester tester) async { | ||
when(mockPostDetailsBloc.state).thenReturn(LoadingPostDetails()); | ||
|
||
await tester.pumpWidget( | ||
makeTestableWidget( | ||
child: MultiBlocProvider( | ||
providers: [ | ||
BlocProvider<PostDetailsBloc>( | ||
create: (_) => mockPostDetailsBloc, | ||
), | ||
BlocProvider<AccountBloc>( | ||
create: (_) => mockAccountBloc, | ||
), | ||
BlocProvider<NavigatorBloc>( | ||
create: (_) => mockNavigatorBloc, | ||
), | ||
], | ||
child: PostDetailsScreen(), | ||
), | ||
), | ||
); | ||
|
||
await tester.pump(const Duration(seconds: 5)); | ||
expect(find.byType(PostDetailsMainContent), findsNothing); | ||
expect(find.byType(PostDetailsLoading), findsOneWidget); | ||
}); | ||
} |
22 changes: 22 additions & 0 deletions
22
test/ui/screens/post_details_screen/widgets/post_details_loading/index_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,22 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mooncake/ui/ui.dart'; | ||
import 'package:flutter/material.dart'; | ||
import '../../../../helper.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/export.dart'; | ||
|
||
void main() { | ||
testWidgets('PostDetailsLoading: Displays correctly', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
makeTestableWidget( | ||
child: PostDetailsLoading(), | ||
), | ||
); | ||
|
||
await tester.pump(const Duration(seconds: 3)); | ||
|
||
expect(find.byType(LoadingIndicator), findsOneWidget); | ||
expect(find.byType(Column), findsOneWidget); | ||
expect(find.text('loadingPost'), findsOneWidget); | ||
}); | ||
} |
89 changes: 89 additions & 0 deletions
89
test/ui/screens/post_details_screen/widgets/post_details_main_content/index_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,89 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:mooncake/ui/ui.dart'; | ||
import '../../../../helper.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/export.dart'; | ||
import '../../../../../mocks/mocks.dart'; | ||
import 'package:mooncake/entities/entities.dart'; | ||
import 'package:mooncake/ui/widgets/post_content/widgets/export.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/post_details_main_content/widgets/export.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/post_details_main_content/widgets/post_comments_list/widgets/export.dart'; | ||
import 'package:mooncake/ui/screens/post_details_screen/widgets/post_details_main_content/widgets/post_details_reactions_list/widgets/export.dart'; | ||
|
||
void main() { | ||
testWidgets('PostDetailsMainContent: Displays correctly', | ||
(WidgetTester tester) async { | ||
MockPostDetailsBloc mockPostDetailsBloc = MockPostDetailsBloc(); | ||
MockAccountBloc mockAccountBloc = MockAccountBloc(); | ||
MockNavigatorBloc mockNavigatorBloc = MockNavigatorBloc(); | ||
MooncakeAccount userAccount = MooncakeAccount( | ||
profilePicUri: "https://example.com/avatar.png", | ||
moniker: "john-doe", | ||
cosmosAccount: CosmosAccount( | ||
accountNumber: 153, | ||
address: "desmos1ew60ztvqxlf5kjjyyzxf7hummlwdadgesu3725", | ||
coins: [ | ||
StdCoin(amount: "10000", denom: "udaric"), | ||
], | ||
sequence: 45, | ||
), | ||
); | ||
|
||
when(mockPostDetailsBloc.state).thenReturn(PostDetailsLoaded.first( | ||
user: userAccount, | ||
post: testPost, | ||
comments: testPosts, | ||
)); | ||
|
||
when(mockAccountBloc.state).thenReturn(LoggedIn.initial(userAccount)); | ||
|
||
await tester.pumpWidget( | ||
makeTestableWidget( | ||
child: MultiBlocProvider( | ||
providers: [ | ||
BlocProvider<PostDetailsBloc>( | ||
create: (_) => mockPostDetailsBloc, | ||
), | ||
BlocProvider<AccountBloc>( | ||
create: (_) => mockAccountBloc, | ||
), | ||
BlocProvider<NavigatorBloc>( | ||
create: (_) => mockNavigatorBloc, | ||
), | ||
], | ||
child: PostDetailsMainContent(), | ||
), | ||
), | ||
); | ||
|
||
await tester.pumpAndSettle(); | ||
expect(find.byType(PostMessage), findsWidgets); | ||
expect(find.byType(LinkPreview), findsNothing); | ||
expect(find.byType(PostItemHeader), findsWidgets); | ||
expect(find.byType(AccountAvatar), findsWidgets); | ||
expect(find.text(testPosts[0].owner.screenName), findsWidgets); | ||
expect(find.byType(InkWell), findsWidgets); | ||
expect(find.byType(PostReactionItem), findsNothing); | ||
expect(find.byType(PostDetailsReactionsList), findsNothing); | ||
expect( | ||
find.descendant( | ||
of: find.byType(PostCommentsList), | ||
matching: find.byType(PostCommentItem), | ||
), | ||
findsWidgets, | ||
); | ||
|
||
// expect(find.byIcon(MooncakeIcons.poll), findsOneWidget); | ||
|
||
await tester.tap(find | ||
.descendant( | ||
of: find.byType(PostCommentsList), | ||
matching: find.byType(PostCommentItem), | ||
) | ||
.first); | ||
await tester.pumpAndSettle(); | ||
expect(verify(mockNavigatorBloc.add(any)).callCount, 1); | ||
}); | ||
} |
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,34 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:mooncake/ui/ui.dart'; | ||
import '../../helper.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() { | ||
MockRecoverAccountBloc mockRecoverAccountBloc = MockRecoverAccountBloc(); | ||
testWidgets('PostDetailsScreen: Displays correctly', | ||
(WidgetTester tester) async { | ||
when(mockRecoverAccountBloc.state) | ||
.thenReturn(RecoverAccountState.initial()); | ||
|
||
await tester.pumpWidget( | ||
makeTestableWidget( | ||
child: MultiBlocProvider( | ||
providers: [ | ||
BlocProvider<RecoverAccountBloc>( | ||
create: (_) => mockRecoverAccountBloc, | ||
), | ||
], | ||
child: RecoverAccountScreen(), | ||
), | ||
), | ||
); | ||
|
||
await tester.pumpAndSettle(); | ||
expect(find.byType(AppBar), findsOneWidget); | ||
expect(find.byType(RecoverAccountMainContent), findsOneWidget); | ||
expect(find.byType(RecoverAccountWordsList), findsOneWidget); | ||
expect(find.text("recoverScreenTitle"), findsOneWidget); | ||
}); | ||
} |
Oops, something went wrong.