Files
eatvio_app/test/features/profile/services/profile_service_test.dart
2025-07-08 11:35:41 +03:00

94 lines
3.2 KiB
Dart

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<ProfileService>()])
void main() {
group('profileService', () {
final mockProfileService = MockProfileService();
test('getMyProfile', () async {
when(mockProfileService.getMyProfile()).thenAnswer(
(_) async => await Future.value(
const ProfileModel(
id: 0,
name: 'Alexander Avanesyan',
email: 'mso7nueh@mail.ru',
isPublicProfile: true,
isEntitySubscribedByMe: false,
isBlockedByMe: false,
slug: 'slug',
profilePhotoUrl: '',
roles: ['user'],
badges: [],
subscriptions: [],
subscribers: [],
),
),
);
expect(await mockProfileService.getMyProfile(), isA<ProfileModel>());
});
test('getProfileDetailsBySlug', () async {
when(mockProfileService.getProfileDetailsBySlug(slug: 'slug')).thenAnswer(
(_) async => await Future.value(
const 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<ProfileDetailsModel>());
});
test('getBlogPostByAuthorSlug', () async {
when(mockProfileService.getBlogPostByAuthorSlug(slug: '')).thenAnswer(
(_) async => [],
);
expect(await mockProfileService.getBlogPostByAuthorSlug(slug: 'slug'), isA<List<FeedBlogPostModel>>());
});
test('getWeight', () async {
when(mockProfileService.getWeight(period: '')).thenAnswer(
(_) async => [],
);
expect(await mockProfileService.getWeight(period: ''), isA<List<WeightModel>>());
});
test('getCircumferences', () async {
when(mockProfileService.getCircumferences(period: '')).thenAnswer(
(_) async => [],
);
expect(await mockProfileService.getCircumferences(period: ''), isA<List<CircumferenceModel>>());
});
});
}