From aaa91a45919e0bbb638ab9e194927ce5718a2bd1 Mon Sep 17 00:00:00 2001 From: lenka369 Date: Sun, 16 Nov 2025 08:53:18 +0100 Subject: [PATCH] Update mock files --- lib/providers/nutrition.dart | 4 - .../nutritional_meal_form_test.mocks.dart | 142 ++++++++++++++---- .../nutritional_plan_form_test.mocks.dart | 142 ++++++++++++++---- 3 files changed, 220 insertions(+), 68 deletions(-) diff --git a/lib/providers/nutrition.dart b/lib/providers/nutrition.dart index a2f9abb2..d1603119 100644 --- a/lib/providers/nutrition.dart +++ b/lib/providers/nutrition.dart @@ -49,10 +49,6 @@ class NutritionPlansProvider with ChangeNotifier { List _plans = []; List ingredients = []; - // Track current search to prevent multiple concurrent requests - String? _currentSearchQuery; - int _searchCounter = 0; - NutritionPlansProvider( this.baseProvider, List entries, { diff --git a/test/nutrition/nutritional_meal_form_test.mocks.dart b/test/nutrition/nutritional_meal_form_test.mocks.dart index 9b9252c2..7762be98 100644 --- a/test/nutrition/nutritional_meal_form_test.mocks.dart +++ b/test/nutrition/nutritional_meal_form_test.mocks.dart @@ -30,37 +30,44 @@ import 'package:wger/providers/nutrition.dart' as _i8; // ignore_for_file: subtype_of_sealed_class // ignore_for_file: invalid_use_of_internal_member -class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider { +class _FakeWgerBaseProvider_0 extends _i1.SmartFake + implements _i2.WgerBaseProvider { _FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase { +class _FakeIngredientDatabase_1 extends _i1.SmartFake + implements _i3.IngredientDatabase { _FakeIngredientDatabase_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan { +class _FakeNutritionalPlan_2 extends _i1.SmartFake + implements _i4.NutritionalPlan { _FakeNutritionalPlan_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { - _FakeMeal_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeMeal_3(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { - _FakeMealItem_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeMealItem_4(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { - _FakeIngredient_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeIngredient_5(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [NutritionPlansProvider]. /// /// See the documentation for Mockito's code generation for more information. -class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansProvider { +class MockNutritionPlansProvider extends _i1.Mock + implements _i8.NutritionPlansProvider { MockNutritionPlansProvider() { _i1.throwOnMissingStub(this); } @@ -69,7 +76,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0(this, Invocation.getter(#baseProvider)), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), ) as _i2.WgerBaseProvider); @@ -77,41 +87,60 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i3.IngredientDatabase get database => (super.noSuchMethod( Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_1(this, Invocation.getter(#database)), + returnValue: _FakeIngredientDatabase_1( + this, + Invocation.getter(#database), + ), ) as _i3.IngredientDatabase); @override List<_i7.Ingredient> get ingredients => - (super.noSuchMethod(Invocation.getter(#ingredients), returnValue: <_i7.Ingredient>[]) + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i7.Ingredient>[], + ) as List<_i7.Ingredient>); @override List<_i4.NutritionalPlan> get items => - (super.noSuchMethod(Invocation.getter(#items), returnValue: <_i4.NutritionalPlan>[]) + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i4.NutritionalPlan>[], + ) as List<_i4.NutritionalPlan>); @override - set database(_i3.IngredientDatabase? value) => - super.noSuchMethod(Invocation.setter(#database, value), returnValueForMissingStub: null); + set database(_i3.IngredientDatabase? value) => super.noSuchMethod( + Invocation.setter(#database, value), + returnValueForMissingStub: null, + ); @override - set ingredients(List<_i7.Ingredient>? value) => - super.noSuchMethod(Invocation.setter(#ingredients, value), returnValueForMissingStub: null); + set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod( + Invocation.setter(#ingredients, value), + returnValueForMissingStub: null, + ); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) + as bool); @override - void clear() => - super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null); + void clear() => super.noSuchMethod( + Invocation.method(#clear, []), + returnValueForMissingStub: null, + ); @override _i4.NutritionalPlan findById(int? id) => (super.noSuchMethod( Invocation.method(#findById, [id]), - returnValue: _FakeNutritionalPlan_2(this, Invocation.method(#findById, [id])), + returnValue: _FakeNutritionalPlan_2( + this, + Invocation.method(#findById, [id]), + ), ) as _i4.NutritionalPlan); @@ -142,7 +171,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#fetchAndSetPlanSparse, [planId]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanSparse, [planId])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#fetchAndSetPlanSparse, [planId]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -152,7 +184,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#fetchAndSetPlanFull, [planId]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanFull, [planId])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#fetchAndSetPlanFull, [planId]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -162,7 +197,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#addPlan, [planData]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#addPlan, [planData])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#addPlan, [planData]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -215,11 +253,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP as _i9.Future); @override - _i9.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, _i5.Meal? meal) => + _i9.Future<_i6.MealItem> addMealItem( + _i6.MealItem? mealItem, + _i5.Meal? meal, + ) => (super.noSuchMethod( Invocation.method(#addMealItem, [mealItem, meal]), returnValue: _i9.Future<_i6.MealItem>.value( - _FakeMealItem_4(this, Invocation.method(#addMealItem, [mealItem, meal])), + _FakeMealItem_4( + this, + Invocation.method(#addMealItem, [mealItem, meal]), + ), ), ) as _i9.Future<_i6.MealItem>); @@ -242,17 +286,41 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP ) as _i9.Future); + @override + _i9.Future cacheIngredient( + _i7.Ingredient? ingredient, { + _i3.IngredientDatabase? database, + }) => + (super.noSuchMethod( + Invocation.method( + #cacheIngredient, + [ingredient], + {#database: database}, + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); + @override _i9.Future<_i7.Ingredient> fetchIngredient( int? ingredientId, { _i3.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method(#fetchIngredient, [ingredientId], {#database: database}), + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), returnValue: _i9.Future<_i7.Ingredient>.value( _FakeIngredient_5( this, - Invocation.method(#fetchIngredient, [ingredientId], {#database: database}), + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), ), ), ) @@ -279,7 +347,9 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP [name], {#languageCode: languageCode, #searchEnglish: searchEnglish}, ), - returnValue: _i9.Future>.value(<_i7.Ingredient>[]), + returnValue: _i9.Future>.value( + <_i7.Ingredient>[], + ), ) as _i9.Future>); @@ -307,7 +377,11 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method(#logIngredientToDiary, [mealItem, planId, dateTime]), + Invocation.method(#logIngredientToDiary, [ + mealItem, + planId, + dateTime, + ]), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) @@ -344,10 +418,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP ); @override - void dispose() => - super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); + void dispose() => super.noSuchMethod( + Invocation.method(#dispose, []), + returnValueForMissingStub: null, + ); @override - void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); + void notifyListeners() => super.noSuchMethod( + Invocation.method(#notifyListeners, []), + returnValueForMissingStub: null, + ); } diff --git a/test/nutrition/nutritional_plan_form_test.mocks.dart b/test/nutrition/nutritional_plan_form_test.mocks.dart index 801f58c3..41196501 100644 --- a/test/nutrition/nutritional_plan_form_test.mocks.dart +++ b/test/nutrition/nutritional_plan_form_test.mocks.dart @@ -30,37 +30,44 @@ import 'package:wger/providers/nutrition.dart' as _i8; // ignore_for_file: subtype_of_sealed_class // ignore_for_file: invalid_use_of_internal_member -class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider { +class _FakeWgerBaseProvider_0 extends _i1.SmartFake + implements _i2.WgerBaseProvider { _FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeIngredientDatabase_1 extends _i1.SmartFake implements _i3.IngredientDatabase { +class _FakeIngredientDatabase_1 extends _i1.SmartFake + implements _i3.IngredientDatabase { _FakeIngredientDatabase_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeNutritionalPlan_2 extends _i1.SmartFake implements _i4.NutritionalPlan { +class _FakeNutritionalPlan_2 extends _i1.SmartFake + implements _i4.NutritionalPlan { _FakeNutritionalPlan_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } class _FakeMeal_3 extends _i1.SmartFake implements _i5.Meal { - _FakeMeal_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeMeal_3(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeMealItem_4 extends _i1.SmartFake implements _i6.MealItem { - _FakeMealItem_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeMealItem_4(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeIngredient_5 extends _i1.SmartFake implements _i7.Ingredient { - _FakeIngredient_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); + _FakeIngredient_5(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [NutritionPlansProvider]. /// /// See the documentation for Mockito's code generation for more information. -class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansProvider { +class MockNutritionPlansProvider extends _i1.Mock + implements _i8.NutritionPlansProvider { MockNutritionPlansProvider() { _i1.throwOnMissingStub(this); } @@ -69,7 +76,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i2.WgerBaseProvider get baseProvider => (super.noSuchMethod( Invocation.getter(#baseProvider), - returnValue: _FakeWgerBaseProvider_0(this, Invocation.getter(#baseProvider)), + returnValue: _FakeWgerBaseProvider_0( + this, + Invocation.getter(#baseProvider), + ), ) as _i2.WgerBaseProvider); @@ -77,41 +87,60 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP _i3.IngredientDatabase get database => (super.noSuchMethod( Invocation.getter(#database), - returnValue: _FakeIngredientDatabase_1(this, Invocation.getter(#database)), + returnValue: _FakeIngredientDatabase_1( + this, + Invocation.getter(#database), + ), ) as _i3.IngredientDatabase); @override List<_i7.Ingredient> get ingredients => - (super.noSuchMethod(Invocation.getter(#ingredients), returnValue: <_i7.Ingredient>[]) + (super.noSuchMethod( + Invocation.getter(#ingredients), + returnValue: <_i7.Ingredient>[], + ) as List<_i7.Ingredient>); @override List<_i4.NutritionalPlan> get items => - (super.noSuchMethod(Invocation.getter(#items), returnValue: <_i4.NutritionalPlan>[]) + (super.noSuchMethod( + Invocation.getter(#items), + returnValue: <_i4.NutritionalPlan>[], + ) as List<_i4.NutritionalPlan>); @override - set database(_i3.IngredientDatabase? value) => - super.noSuchMethod(Invocation.setter(#database, value), returnValueForMissingStub: null); + set database(_i3.IngredientDatabase? value) => super.noSuchMethod( + Invocation.setter(#database, value), + returnValueForMissingStub: null, + ); @override - set ingredients(List<_i7.Ingredient>? value) => - super.noSuchMethod(Invocation.setter(#ingredients, value), returnValueForMissingStub: null); + set ingredients(List<_i7.Ingredient>? value) => super.noSuchMethod( + Invocation.setter(#ingredients, value), + returnValueForMissingStub: null, + ); @override bool get hasListeners => - (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); + (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) + as bool); @override - void clear() => - super.noSuchMethod(Invocation.method(#clear, []), returnValueForMissingStub: null); + void clear() => super.noSuchMethod( + Invocation.method(#clear, []), + returnValueForMissingStub: null, + ); @override _i4.NutritionalPlan findById(int? id) => (super.noSuchMethod( Invocation.method(#findById, [id]), - returnValue: _FakeNutritionalPlan_2(this, Invocation.method(#findById, [id])), + returnValue: _FakeNutritionalPlan_2( + this, + Invocation.method(#findById, [id]), + ), ) as _i4.NutritionalPlan); @@ -142,7 +171,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#fetchAndSetPlanSparse, [planId]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanSparse, [planId])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#fetchAndSetPlanSparse, [planId]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -152,7 +184,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#fetchAndSetPlanFull, [planId]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#fetchAndSetPlanFull, [planId])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#fetchAndSetPlanFull, [planId]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -162,7 +197,10 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP (super.noSuchMethod( Invocation.method(#addPlan, [planData]), returnValue: _i9.Future<_i4.NutritionalPlan>.value( - _FakeNutritionalPlan_2(this, Invocation.method(#addPlan, [planData])), + _FakeNutritionalPlan_2( + this, + Invocation.method(#addPlan, [planData]), + ), ), ) as _i9.Future<_i4.NutritionalPlan>); @@ -215,11 +253,17 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP as _i9.Future); @override - _i9.Future<_i6.MealItem> addMealItem(_i6.MealItem? mealItem, _i5.Meal? meal) => + _i9.Future<_i6.MealItem> addMealItem( + _i6.MealItem? mealItem, + _i5.Meal? meal, + ) => (super.noSuchMethod( Invocation.method(#addMealItem, [mealItem, meal]), returnValue: _i9.Future<_i6.MealItem>.value( - _FakeMealItem_4(this, Invocation.method(#addMealItem, [mealItem, meal])), + _FakeMealItem_4( + this, + Invocation.method(#addMealItem, [mealItem, meal]), + ), ), ) as _i9.Future<_i6.MealItem>); @@ -242,17 +286,41 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP ) as _i9.Future); + @override + _i9.Future cacheIngredient( + _i7.Ingredient? ingredient, { + _i3.IngredientDatabase? database, + }) => + (super.noSuchMethod( + Invocation.method( + #cacheIngredient, + [ingredient], + {#database: database}, + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) + as _i9.Future); + @override _i9.Future<_i7.Ingredient> fetchIngredient( int? ingredientId, { _i3.IngredientDatabase? database, }) => (super.noSuchMethod( - Invocation.method(#fetchIngredient, [ingredientId], {#database: database}), + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), returnValue: _i9.Future<_i7.Ingredient>.value( _FakeIngredient_5( this, - Invocation.method(#fetchIngredient, [ingredientId], {#database: database}), + Invocation.method( + #fetchIngredient, + [ingredientId], + {#database: database}, + ), ), ), ) @@ -279,7 +347,9 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP [name], {#languageCode: languageCode, #searchEnglish: searchEnglish}, ), - returnValue: _i9.Future>.value(<_i7.Ingredient>[]), + returnValue: _i9.Future>.value( + <_i7.Ingredient>[], + ), ) as _i9.Future>); @@ -307,7 +377,11 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP DateTime? dateTime, ]) => (super.noSuchMethod( - Invocation.method(#logIngredientToDiary, [mealItem, planId, dateTime]), + Invocation.method(#logIngredientToDiary, [ + mealItem, + planId, + dateTime, + ]), returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) @@ -344,10 +418,14 @@ class MockNutritionPlansProvider extends _i1.Mock implements _i8.NutritionPlansP ); @override - void dispose() => - super.noSuchMethod(Invocation.method(#dispose, []), returnValueForMissingStub: null); + void dispose() => super.noSuchMethod( + Invocation.method(#dispose, []), + returnValueForMissingStub: null, + ); @override - void notifyListeners() => - super.noSuchMethod(Invocation.method(#notifyListeners, []), returnValueForMissingStub: null); + void notifyListeners() => super.noSuchMethod( + Invocation.method(#notifyListeners, []), + returnValueForMissingStub: null, + ); }