feat: introduce DiaryCubit for managing user diary and diet plans, and add new unit tests for various features.

This commit is contained in:
mso7nueh
2026-01-27 14:33:21 +03:00
parent a93da1b505
commit 79df8c5f9a
4 changed files with 7 additions and 5 deletions

View File

@@ -126,7 +126,7 @@ class DiaryCubit extends Cubit<DiaryState> {
return diaryDay;
}
}
rethrow;
return null;
}
}

View File

@@ -433,6 +433,7 @@ void main() {
final tempFile = File('${Directory.systemTemp.path}/test_image.jpg');
await tempFile.writeAsBytes([1, 2, 3]);
cubit.replaceImage(tempFile);
cubit.replaceDescriptionInStep('Step 1 description', 0);
expect(cubit.validateAll(), true);
});

View File

@@ -244,7 +244,8 @@ void main() {
await tester.pump();
// Assert
expect(find.text('Закончить день'), findsOneWidget);
// Теперь на экране 2 текста "Закончить день": один на кнопке, другой в заголовке bottom sheet
expect(find.text('Закончить день'), findsNWidgets(2));
});
testWidgets('should display MealWidget with mood rating when showMood is true', (WidgetTester tester) async {

View File

@@ -192,7 +192,7 @@ void main() {
});
test('sendEmailCode - обработка ошибки', () async {
cubit = VerifyEmailCubit(profileRepository: mockRepository);
cubit = VerifyEmailCubit(profileRepository: mockRepository, prefs: mockPrefs);
when(mockRepository.getMyProfile()).thenThrow(Exception('Network error'));
@@ -204,7 +204,7 @@ void main() {
});
test('tryVerify - обработка ошибки при верификации', () async {
cubit = VerifyEmailCubit(profileRepository: mockRepository);
cubit = VerifyEmailCubit(profileRepository: mockRepository, prefs: mockPrefs);
when(mockRepository.tryVerifyEmailByCode('123456')).thenThrow(Exception('Network error'));
@@ -214,7 +214,7 @@ void main() {
});
test('changeEmail - обработка ошибки', () async {
cubit = VerifyEmailCubit(profileRepository: mockRepository);
cubit = VerifyEmailCubit(profileRepository: mockRepository, prefs: mockPrefs);
when(mockRepository.sendEmailCode(newEmail: 'new@example.com')).thenThrow(Exception('Network error'));