feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing

This commit is contained in:
mso7nueh
2025-12-04 15:45:54 +03:00
parent 0cd8e662d9
commit 953230b387
100 changed files with 7202 additions and 14 deletions

View File

@@ -0,0 +1,76 @@
import 'package:eatvio_app/features/feed/presentation/bloc/profile_cubit/profile_cubit.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'profile_cubit_test.mocks.dart';
@GenerateNiceMocks([MockSpec<ProfileRepository>()])
void main() {
group('FeedProfileCubit', () {
FeedProfileCubit? cubit;
late MockProfileRepository mockRepository;
setUp(() {
mockRepository = MockProfileRepository();
});
tearDown(() async {
if (cubit != null && !cubit!.isClosed) {
await cubit!.close();
cubit = null;
}
});
test('начальное состояние - с null профилем', () {
cubit = FeedProfileCubit(profileRepository: mockRepository);
expect(cubit!.state.profile, isNull);
});
test('getProfile - успешная загрузка профиля', () async {
cubit = FeedProfileCubit(profileRepository: mockRepository);
const testProfile = ProfileModel(
id: 1,
slug: 'test-user',
name: 'Test User',
email: 'test@example.com',
phoneConfirmationState: 'confirmed',
isPublicProfile: true,
isBlockedByMe: false,
isBlockedByAuthor: false,
isBlockedByUser: false,
isEntitySubscribedByMe: false,
profilePhotoUrl: 'https://example.com/icon.jpg',
roles: [],
badges: [],
subscriptions: [],
subscribers: [],
);
when(mockRepository.getMyProfile())
.thenAnswer((_) async => testProfile);
await cubit!.getProfile();
expect(cubit!.state.profile, isNotNull);
expect(cubit!.state.profile!.id, 1);
});
test('getProfile - обработка ошибки', () async {
cubit = FeedProfileCubit(profileRepository: mockRepository);
when(mockRepository.getMyProfile())
.thenThrow(Exception('Ошибка загрузки'));
await cubit!.getProfile();
// Состояние не должно измениться при ошибке
expect(cubit!.state.profile, isNull);
});
});
}