forked from eatvio/eatvio_app
feat: introduce DiaryCubit for managing user diary and diet plans, and add new unit tests for various features.
This commit is contained in:
@@ -126,7 +126,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
return diaryDay;
|
||||
}
|
||||
}
|
||||
rethrow;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user