From faa417d1832491dd7fbda4fdfe6c91bea54984ee Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 4 May 2024 14:20:08 +0200 Subject: [PATCH] fix test --- lib/models/nutrition/nutritional_goals.dart | 17 +++++++++++++++++ test/nutrition/nutritional_plan_model_test.dart | 13 +++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/models/nutrition/nutritional_goals.dart b/lib/models/nutrition/nutritional_goals.dart index 5d7086fe..0112c9b0 100644 --- a/lib/models/nutrition/nutritional_goals.dart +++ b/lib/models/nutrition/nutritional_goals.dart @@ -139,4 +139,21 @@ class NutritionalGoals { //ignore: avoid_equals_and_hash_code_on_mutable_classes int get hashCode => Object.hash( energy, protein, carbohydrates, carbohydratesSugar, fat, fatSaturated, fibres, sodium); + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + return other is NutritionalGoals && + other.energy == energy && + other.protein == protein && + other.carbohydrates == carbohydrates && + other.carbohydratesSugar == carbohydratesSugar && + other.fat == fat && + other.fatSaturated == fatSaturated && + other.fibres == fibres && + other.sodium == sodium; + } } diff --git a/test/nutrition/nutritional_plan_model_test.dart b/test/nutrition/nutritional_plan_model_test.dart index 23b09d34..172fca5b 100644 --- a/test/nutrition/nutritional_plan_model_test.dart +++ b/test/nutrition/nutritional_plan_model_test.dart @@ -32,8 +32,17 @@ void main() { group('model tests', () { test('Test the nutritionalValues method for nutritional plans', () { - final values = NutritionalValues.values(4118.75, 32.75, 347.5, 9.5, 59.0, 37.75, 52.5, 30.5); - expect(plan.nutritionalGoals, values); + expect( + plan.nutritionalGoals, + NutritionalGoals( + energy: 4118.75, + protein: 32.75, + carbohydrates: 347.5, + carbohydratesSugar: 9.5, + fat: 59.0, + fatSaturated: 37.75, + fibres: 52.5, + sodium: 30.5)); }); test('Test the nutritionalValues method for meals', () {