From 0502c459af031e745903d25eef4e8a2f091a7f91 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 21 Apr 2024 18:39:58 +0200 Subject: [PATCH] Fix tests --- test/nutrition/nutritional_meal_form_test.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/nutrition/nutritional_meal_form_test.dart b/test/nutrition/nutritional_meal_form_test.dart index 34a87b5b..bd84eef8 100644 --- a/test/nutrition/nutritional_meal_form_test.dart +++ b/test/nutrition/nutritional_meal_form_test.dart @@ -50,7 +50,7 @@ void main() { mockNutrition = MockNutritionPlansProvider(); }); - Widget createHomeScreen(Meal meal, {locale = 'en'}) { + Widget createFormScreen(Meal meal, {locale = 'en'}) { final key = GlobalKey(); return ChangeNotifierProvider( @@ -71,7 +71,7 @@ void main() { } testWidgets('Test the widgets on the meal form', (WidgetTester tester) async { - await tester.pumpWidget(createHomeScreen(meal1)); + await tester.pumpWidget(createFormScreen(meal1)); await tester.pumpAndSettle(); expect(find.byType(TextFormField), findsNWidgets(2)); @@ -80,7 +80,7 @@ void main() { }); testWidgets('Test editing an existing meal', (WidgetTester tester) async { - await tester.pumpWidget(createHomeScreen(meal1)); + await tester.pumpWidget(createFormScreen(meal1)); await tester.pumpAndSettle(); expect( @@ -114,9 +114,12 @@ void main() { // The time set in the meal object is what is displayed by default // and can be matched with the find.text function. By creating the meal // wrapped in the withClock it also shares the same now value. - final fixedTimeMeal = Meal(); - await tester.pumpWidget(createHomeScreen(fixedTimeMeal)); + // Note: it seems there is something wrong with withClock that seems to + // get ignored, so passing the time to the constructor for now + final fixedTimeMeal = Meal(time: const TimeOfDay(hour: 1, minute: 1)); + + await tester.pumpWidget(createFormScreen(fixedTimeMeal)); await tester.pumpAndSettle(); expect(