diff --git a/test/features/profile/services/profile_service_test.dart b/test/features/profile/services/profile_service_test.dart new file mode 100644 index 00000000..4db6526b --- /dev/null +++ b/test/features/profile/services/profile_service_test.dart @@ -0,0 +1,92 @@ +import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; +import 'package:eatvio_app/features/profile/services/profile_service.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'profile_service_test.mocks.dart'; + +@GenerateNiceMocks([MockSpec()]) +void main() { + group('profileService', () { + final mockProfileService = MockProfileService(); + test('getMyProfile', () async { + when(mockProfileService.getMyProfile()).thenAnswer( + (_) async => await Future.value( + ProfileModel( + id: 0, + name: 'Alexander Avanesyan', + email: 'mso7nueh@mail.ru', + isPublicProfile: true, + isEntitySubscribedByMe: false, + slug: 'slug', + profilePhotoUrl: '', + role: 'user', + badges: [], + subscriptions: [], + subscribers: [], + ), + ), + ); + expect(await mockProfileService.getMyProfile(), isA()); + }); + + test('getProfileDetailsBySlug', () async { + when(mockProfileService.getProfileDetailsBySlug(slug: 'slug')).thenAnswer( + (_) async => await Future.value( + ProfileDetailsModel( + firstName: 'Alexnader', + lastName: 'Avanesyan', + birthdate: '2024-05-28', + gender: 'male', + country: 'Russia', + city: 'Moscow', + lang: 'Russian', + weight: 84, + height: 178, + chestCircumference: 100, + waistCircumference: 80, + hipCircumference: 90, + bloodPressureUp: 120, + bloodPressureDown: 80, + hasHypo: false, + hasHyper: false, + aboutAlergy: '', + aboutTakingPils: '', + aboutSportHobbies: 'Judo', + favoriteFoods: '', + unfavoriteFoods: '', + additionalInfo: '10 lvl faceit', + isMoodFillable: true, + isBedtimeFillable: true, + activityCoefficient: 2, + ), + ), + ); + expect(await mockProfileService.getProfileDetailsBySlug(slug: 'slug'), isA()); + }); + + test('getBlogPostByAuthorSlug', () async { + when(mockProfileService.getBlogPostByAuthorSlug(slug: '')).thenAnswer( + (_) async => [], + ); + expect(await mockProfileService.getBlogPostByAuthorSlug(slug: 'slug'), isA>()); + }); + + test('getWeight', () async { + when(mockProfileService.getWeight(period: '')).thenAnswer( + (_) async => [], + ); + expect(await mockProfileService.getWeight(period: ''), isA>()); + }); + + test('getCircumferences', () async { + when(mockProfileService.getCircumferences(period: '')).thenAnswer( + (_) async => [], + ); + expect(await mockProfileService.getCircumferences(period: ''), isA>()); + }); + }); +} diff --git a/test/profile_service_test.mocks.dart b/test/features/profile/services/profile_service_test.mocks.dart similarity index 100% rename from test/profile_service_test.mocks.dart rename to test/features/profile/services/profile_service_test.mocks.dart diff --git a/test/profile_service_test.dart b/test/profile_service_test.dart deleted file mode 100644 index 5df6d580..00000000 --- a/test/profile_service_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:eatvio_app/features/profile/models/profile_model.dart'; -import 'package:eatvio_app/features/profile/services/profile_service.dart'; -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'profile_service_test.mocks.dart'; - -@GenerateNiceMocks([MockSpec()]) -void main() { - group('fetchProfile', () { - final mockProfileService = MockProfileService(); - - test('getMyProfile', () async { - when(mockProfileService.getMyProfile()).thenAnswer( - (_) async => ProfileModel( - id: 0, - name: 'Alexander Avanesyan', - email: 'mso7nueh@mail.ru', - isPublicProfile: true, - isEntitySubscribedByMe: false, - slug: 'slug', - profilePhotoUrl: '', - role: 'user', - badges: [], - subscriptions: [], - subscribers: [], - ), - ); - expect(await mockProfileService.getMyProfile(), isA()); - }); - }); -}