From 7c3b7a61a94d3f811a683cd1cf05554d656b4bf2 Mon Sep 17 00:00:00 2001 From: Mathias Mogensen Date: Tue, 28 Feb 2023 17:28:58 +0100 Subject: [PATCH] fix: tests and formatter --- lib/presentation/profile/profile_screen.dart | 17 ----- .../user/profile/profile_bloc_test.dart | 69 ------------------- .../profile/profile_screen_test.dart | 4 +- 3 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 test/application/user/profile/profile_bloc_test.dart diff --git a/lib/presentation/profile/profile_screen.dart b/lib/presentation/profile/profile_screen.dart index 40e03b83..ea260b62 100644 --- a/lib/presentation/profile/profile_screen.dart +++ b/lib/presentation/profile/profile_screen.dart @@ -4,7 +4,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; -import 'package:ionicons/ionicons.dart'; import 'package:share_plus/share_plus.dart'; import '../../application/user/profile/profile_bloc.dart'; @@ -153,21 +152,6 @@ class _UserProfilePageState extends State { ), ), ), - // Positioned( - // bottom: 0, - // left: 0, - // child: FloatingActionButton( - // onPressed: () { - // BlocProvider.of(context) - // .add(CancelEditProfilePic()); - - // _image = null; - // }, - // backgroundColor: kErrorColor, - // mini: true, - // child: const Icon(Icons.close), - // ), - // ), ] ], ), @@ -209,7 +193,6 @@ class _UserProfilePageState extends State { onPressed: () { if (state.isBioEditing == true) { /// TODO: Implement save profile image - BlocProvider.of(context).add( SaveBio( bio: bioController.text, diff --git a/test/application/user/profile/profile_bloc_test.dart b/test/application/user/profile/profile_bloc_test.dart deleted file mode 100644 index f83def18..00000000 --- a/test/application/user/profile/profile_bloc_test.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:bloc_test/bloc_test.dart'; -import 'package:collaction_app/application/user/profile/profile_bloc.dart'; -import 'package:collaction_app/domain/user/i_avatar_repository.dart'; -import 'package:collaction_app/domain/user/i_profile_repository.dart'; -import 'package:collaction_app/domain/user/profile_failure.dart'; -import 'package:dartz/dartz.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:mocktail/mocktail.dart'; - -import '../../../domain/user/user_fixture.dart'; -import '../../../test_utilities.dart'; - -void main() { - late IProfileRepository profileRepository; - late IAvatarRepository avatarRepository; - late ProfileBloc profileBloc; - - const userProfile = cUserProfile; - - setUp(() { - profileRepository = MockProfileRepository(); - avatarRepository = MockAvatarRepository(); - profileBloc = ProfileBloc(profileRepository, avatarRepository); - }); - - test('should have [ProfileState.initial()] as initial state', () async { - /// assert - expect(profileBloc.state, equals(ProfileState.initial())); - }); - - blocTest( - 'should return [ProfileState] with user profile ' - 'when profile retrieval is successful', - setUp: () { - when(() => profileRepository.getUserProfile()) - .thenAnswer((_) async => const Right(userProfile)); - }, - build: () => profileBloc, - act: (bloc) => [bloc.add(GetUserProfile())], - expect: () => const [ - ProfileState( - userProfile: userProfile, - isPicEditing: false, - wasProfilePictureUpdated: false, - ) - ], - verify: (_) => verify(() => profileRepository.getUserProfile()).called(1), - ); - - blocTest( - 'should return [ProfileState] with null user profile ' - 'when profile retrieval is not successful', - setUp: () { - when(() => profileRepository.getUserProfile()) - .thenAnswer((_) async => const Left(ProfileFailure.unexpected())); - }, - build: () => profileBloc, - act: (bloc) => [bloc.add(GetUserProfile())], - expect: () => const [ - ProfileState( - userProfile: null, - isPicEditing: false, - ) - ], - verify: (_) => verify(() => profileRepository.getUserProfile()).called(1), - ); - - /// TODO(obella): Add more tests -} diff --git a/test/presentation/profile/profile_screen_test.dart b/test/presentation/profile/profile_screen_test.dart index 45960ed8..3de6e058 100644 --- a/test/presentation/profile/profile_screen_test.dart +++ b/test/presentation/profile/profile_screen_test.dart @@ -156,9 +156,9 @@ void main() { expect(find.byType(UserProfilePage), findsOneWidget); - profileBloc.add(EditProfile()); + profileBloc.add(EditBio()); await tester.pumpAndSettle(); - expect(profileBloc.state.isEditing, true); + expect(profileBloc.state.isBioEditing, true); }); }