73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
|
|
import 'package:eatvio_app/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart';
|
|
import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_model.dart';
|
|
|
|
void main() {
|
|
group('DiaryEditScreen', () {
|
|
/*testWidgets('renders CircularProgressIndicator when in initial state',
|
|
(WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: DiaryEditScreen(),
|
|
),
|
|
);
|
|
});*/
|
|
|
|
testWidgets('renders _buildDiaryEditScreen when in loaded state',
|
|
(WidgetTester tester) async {
|
|
final diaryEditBloc =
|
|
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()));
|
|
final loadedState = DiaryEditLoadedState(
|
|
diaryId: 1,
|
|
selectedSatiety: 4,
|
|
autocompleteList: [],
|
|
portions: [],
|
|
wakeupExpanded: false,
|
|
moderationExpanded: false,
|
|
moodExpanded: false);
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: BlocProvider<DiaryEditBloc>.value(
|
|
value: diaryEditBloc,
|
|
child: DiaryEditScreen(
|
|
onInitialize: () {},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
diaryEditBloc.emit(loadedState);
|
|
await tester.pump();
|
|
|
|
//expect(find.byType(_buildDiaryEditScreen), findsOneWidget);
|
|
});
|
|
|
|
/*testWidgets('renders error message when in error state',
|
|
(WidgetTester tester) async {
|
|
final diaryEditBloc =
|
|
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()));
|
|
final errorState = DiaryEditErrorState("error");
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: BlocProvider<DiaryEditBloc>.value(
|
|
value: diaryEditBloc,
|
|
child: DiaryEditScreen(),
|
|
),
|
|
),
|
|
);
|
|
|
|
diaryEditBloc.emit(errorState);
|
|
await tester.pump();
|
|
|
|
expect(find.text('Ошибка'), findsOneWidget);
|
|
});*/
|
|
|
|
// Add more tests for other scenarios if needed
|
|
});
|
|
}
|