From 1ae3eafd720afb9051bb5d2041ed78cc00399509 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 4 May 2024 18:13:24 +0200 Subject: [PATCH] more tests --- .../nutritional_plan_model_test.dart | 51 ++++++++++++++++++- .../nutritional_plan_screen_test.dart | 2 - 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/test/nutrition/nutritional_plan_model_test.dart b/test/nutrition/nutritional_plan_model_test.dart index 172fca5bb..096e837e4 100644 --- a/test/nutrition/nutritional_plan_model_test.dart +++ b/test/nutrition/nutritional_plan_model_test.dart @@ -31,7 +31,7 @@ void main() { }); group('model tests', () { - test('Test the nutritionalValues method for nutritional plans', () { + test('Test NutritionalPlan.nutritionalGoals based on meals', () { expect( plan.nutritionalGoals, NutritionalGoals( @@ -44,6 +44,55 @@ void main() { fibres: 52.5, sodium: 30.5)); }); + test('Test NutritionalPlan.nutritionalValues based on 3 macros and energy', () { + expect( + NutritionalPlan( + description: '3 macros and energy defined', + creationDate: DateTime(2024, 5, 4), + goalProtein: 150, + goalCarbohydrates: 100, + goalFat: 100, + goalEnergy: 1500, + ).nutritionalGoals, + NutritionalGoals( + energy: 1500, + protein: 150, + carbohydrates: 100, + fat: 100, + )); + }); + test('Test NutritionalPlan.nutritionalValues based on 2 macros and energy', () { + expect( + NutritionalPlan( + description: '2 macros and energy defined', + creationDate: DateTime(2024, 5, 4), + goalProtein: 100, + goalCarbohydrates: 100, + goalEnergy: 1700, + ).nutritionalGoals, + NutritionalGoals( + energy: 1700, + protein: 100, + carbohydrates: 100, + fat: 100, // inferred + )); + }); + test('Test NutritionalPlan.nutritionalValues based on 3 macros only', () { + expect( + NutritionalPlan( + description: '3 macros defined', + creationDate: DateTime(2024, 5, 4), + goalProtein: 100, + goalCarbohydrates: 100, + goalFat: 10, + ).nutritionalGoals, + NutritionalGoals( + energy: 890, // inferred + protein: 100, + carbohydrates: 100, + fat: 10, + )); + }); test('Test the nutritionalValues method for meals', () { final meal = plan.meals.first; diff --git a/test/nutrition/nutritional_plan_screen_test.dart b/test/nutrition/nutritional_plan_screen_test.dart index a3e5103ab..8caeefcfd 100644 --- a/test/nutrition/nutritional_plan_screen_test.dart +++ b/test/nutrition/nutritional_plan_screen_test.dart @@ -27,8 +27,6 @@ import 'package:wger/providers/base_provider.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/providers/nutrition.dart'; import 'package:wger/screens/nutritional_plan_screen.dart'; -import 'package:wger/widgets/nutrition/charts.dart'; - import '../../test_data/nutritional_plans.dart'; import 'nutritional_plan_screen_test.mocks.dart';