Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed May 4, 2024
1 parent faa417d commit 1ae3eaf
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
51 changes: 50 additions & 1 deletion test/nutrition/nutritional_plan_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions test/nutrition/nutritional_plan_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 1ae3eaf

Please sign in to comment.