forked from eatvio/eatvio_app
feat(tests): added new tests and updated fixtures
This commit is contained in:
@@ -3,11 +3,58 @@
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Авокадо",
|
||||
"portion": "grams",
|
||||
"portion": "gr",
|
||||
"quantity": 100,
|
||||
"product_nutritional_value_id": "501"
|
||||
"product_nutritional_value_id": 501,
|
||||
"nutrition": {
|
||||
"energy": 160.0,
|
||||
"proteins": 2.0,
|
||||
"fats": 14.0,
|
||||
"carbohydrates": 9.0
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"name": "Лосось",
|
||||
"portion": "gr",
|
||||
"quantity": 150,
|
||||
"product_nutritional_value_id": 502,
|
||||
"nutrition": {
|
||||
"energy": 312.0,
|
||||
"proteins": 30.0,
|
||||
"fats": 19.5,
|
||||
"carbohydrates": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"0": {
|
||||
"name": "Овсянка",
|
||||
"portion": "gr",
|
||||
"quantity": 150,
|
||||
"product_nutritional_value_id": 503,
|
||||
"nutrition": {
|
||||
"energy": 195.0,
|
||||
"proteins": 6.75,
|
||||
"fats": 3.0,
|
||||
"carbohydrates": 33.0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Творог",
|
||||
"portion": "gr",
|
||||
"quantity": 200,
|
||||
"product_nutritional_value_id": 504,
|
||||
"nutrition": {
|
||||
"energy": 226.0,
|
||||
"proteins": 31.0,
|
||||
"fats": 9.0,
|
||||
"carbohydrates": 3.4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
77
test/fixtures/diets/diet_response.json
vendored
77
test/fixtures/diets/diet_response.json
vendored
@@ -12,7 +12,66 @@
|
||||
"meat": false
|
||||
},
|
||||
"description_md": "Test details",
|
||||
"daily_schedule": {},
|
||||
"daily_schedule": {
|
||||
"1": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Овсянка",
|
||||
"portion": "gr",
|
||||
"quantity": 150,
|
||||
"product_nutritional_value_id": 101,
|
||||
"nutrition": {
|
||||
"energy": 195.0,
|
||||
"proteins": 6.75,
|
||||
"fats": 3.0,
|
||||
"carbohydrates": 33.0
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"name": "Бананы",
|
||||
"portion": "gr",
|
||||
"quantity": 120,
|
||||
"product_nutritional_value_id": 102,
|
||||
"nutrition": {
|
||||
"energy": 107.0,
|
||||
"proteins": 1.3,
|
||||
"fats": 0.4,
|
||||
"carbohydrates": 27.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"0": {
|
||||
"name": "Куриная грудка",
|
||||
"portion": "gr",
|
||||
"quantity": 200,
|
||||
"product_nutritional_value_id": 201,
|
||||
"nutrition": {
|
||||
"energy": 330.0,
|
||||
"proteins": 62.0,
|
||||
"fats": 7.2,
|
||||
"carbohydrates": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Творог",
|
||||
"portion": "gr",
|
||||
"quantity": 200,
|
||||
"product_nutritional_value_id": 301,
|
||||
"nutrition": {
|
||||
"energy": 226.0,
|
||||
"proteins": 31.0,
|
||||
"fats": 9.0,
|
||||
"carbohydrates": 3.4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"author_slug": "author",
|
||||
"author_name": "Author Name",
|
||||
@@ -26,6 +85,18 @@
|
||||
"total_comments": 5,
|
||||
"was_liked_by_me": false,
|
||||
"is_favorite": false,
|
||||
"daily_nutrition": []
|
||||
"daily_nutrition": [
|
||||
{
|
||||
"energy": 864.0,
|
||||
"proteins": 101.05,
|
||||
"fats": 19.6,
|
||||
"carbohydrates": 63.4
|
||||
},
|
||||
{
|
||||
"energy": 532.0,
|
||||
"proteins": 93.3,
|
||||
"fats": 16.2,
|
||||
"carbohydrates": 30.4
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
22
test/fixtures/doubles/create_diet_doubles.dart
vendored
22
test/fixtures/doubles/create_diet_doubles.dart
vendored
@@ -53,11 +53,15 @@ class FixtureCreateDietRepository extends CreateDietRepository {
|
||||
portion = Portion.grams;
|
||||
}
|
||||
|
||||
final pnvid = portionData['product_nutritional_value_id'];
|
||||
final nutritionJson = portionData['nutrition'] as Map<String, dynamic>?;
|
||||
final dailyNutrition = nutritionJson != null ? DailyNutrition.fromJson(nutritionJson) : null;
|
||||
mealMap[portionIndex] = DailySchedule(
|
||||
name: portionData['name'] as String,
|
||||
portion: portion,
|
||||
quantity: portionData['quantity'] as int,
|
||||
productNutritionalValueId: portionData['product_nutritional_value_id'] as String?,
|
||||
quantity: portionData['quantity'] is int ? portionData['quantity'] as int : int.parse(portionData['quantity'].toString()),
|
||||
productNutritionalValueId: pnvid == null ? null : (pnvid is int ? pnvid : int.tryParse(pnvid.toString())),
|
||||
dailyNutrition: dailyNutrition,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -75,13 +79,13 @@ class FixtureCreateDietRepository extends CreateDietRepository {
|
||||
required String name,
|
||||
required int duration,
|
||||
required DietState state,
|
||||
required String meatType,
|
||||
required String carbType,
|
||||
required String vegType,
|
||||
required String lightType,
|
||||
required String details,
|
||||
required File image,
|
||||
required List<List<List<DailySchedule>>> dailySchedule,
|
||||
required String? meatType,
|
||||
required String? carbType,
|
||||
required String? vegType,
|
||||
required String? lightType,
|
||||
required String? details,
|
||||
required File? image,
|
||||
required List<List<List<DailySchedule>>>? dailySchedule,
|
||||
}) async {
|
||||
createRequests.add(<String, dynamic>{
|
||||
'name': name,
|
||||
|
||||
@@ -14,7 +14,54 @@
|
||||
"meat": true
|
||||
},
|
||||
"description_md": "Keto diet description",
|
||||
"daily_schedule": {},
|
||||
"daily_schedule": {
|
||||
"1": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Яйца вареные",
|
||||
"portion": "pcs",
|
||||
"quantity": 2,
|
||||
"product_nutritional_value_id": 401,
|
||||
"nutrition": {
|
||||
"energy": 155.0,
|
||||
"proteins": 12.6,
|
||||
"fats": 10.6,
|
||||
"carbohydrates": 1.1
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"0": {
|
||||
"name": "Авокадо",
|
||||
"portion": "gr",
|
||||
"quantity": 100,
|
||||
"product_nutritional_value_id": 501,
|
||||
"nutrition": {
|
||||
"energy": 160.0,
|
||||
"proteins": 2.0,
|
||||
"fats": 14.0,
|
||||
"carbohydrates": 9.0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Лосось",
|
||||
"portion": "gr",
|
||||
"quantity": 150,
|
||||
"product_nutritional_value_id": 502,
|
||||
"nutrition": {
|
||||
"energy": 312.0,
|
||||
"proteins": 30.0,
|
||||
"fats": 19.5,
|
||||
"carbohydrates": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"author_slug": "nutritionist-1",
|
||||
"author_name": "Nutritionist Name",
|
||||
@@ -28,7 +75,20 @@
|
||||
"total_comments": 25,
|
||||
"was_liked_by_me": false,
|
||||
"is_favorite": false,
|
||||
"daily_nutrition": []
|
||||
"daily_nutrition": [
|
||||
{
|
||||
"energy": 627.0,
|
||||
"proteins": 44.6,
|
||||
"fats": 44.1,
|
||||
"carbohydrates": 10.1
|
||||
},
|
||||
{
|
||||
"energy": 312.0,
|
||||
"proteins": 30.0,
|
||||
"fats": 19.5,
|
||||
"carbohydrates": 0.0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"links": {
|
||||
@@ -50,4 +110,3 @@
|
||||
"total_max_price": null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
112
test/fixtures/my_diets/my_diets_pagination_response.json
vendored
Normal file
112
test/fixtures/my_diets/my_diets_pagination_response.json
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": 1,
|
||||
"slug": "my-keto-diet",
|
||||
"name": "My Keto Diet",
|
||||
"image": "https://example.com/my-keto.jpg",
|
||||
"duration": 14,
|
||||
"state": "drafted",
|
||||
"type": {
|
||||
"light": true,
|
||||
"veg": true,
|
||||
"carb": false,
|
||||
"meat": true
|
||||
},
|
||||
"description_md": "My drafted keto diet for two weeks",
|
||||
"daily_schedule": {
|
||||
"1": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Омлет",
|
||||
"portion": "gr",
|
||||
"quantity": 200,
|
||||
"product_nutritional_value_id": 601,
|
||||
"nutrition": {
|
||||
"energy": 318.0,
|
||||
"proteins": 21.2,
|
||||
"fats": 24.2,
|
||||
"carbohydrates": 2.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"0": {
|
||||
"name": "Салат с курицей",
|
||||
"portion": "gr",
|
||||
"quantity": 300,
|
||||
"product_nutritional_value_id": 602,
|
||||
"nutrition": {
|
||||
"energy": 285.0,
|
||||
"proteins": 35.0,
|
||||
"fats": 12.0,
|
||||
"carbohydrates": 8.0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"1": {
|
||||
"0": {
|
||||
"name": "Творог 5%",
|
||||
"portion": "gr",
|
||||
"quantity": 200,
|
||||
"product_nutritional_value_id": 603,
|
||||
"nutrition": {
|
||||
"energy": 226.0,
|
||||
"proteins": 31.0,
|
||||
"fats": 9.0,
|
||||
"carbohydrates": 3.4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"author_slug": "me",
|
||||
"author_name": "My Name",
|
||||
"author_profile_icon": "https://example.com/me.jpg",
|
||||
"author_is_me": true,
|
||||
"is_entity_subscribed_by_me": null,
|
||||
"author_place_in_rating": null
|
||||
},
|
||||
"total_likes": 0,
|
||||
"total_views": 0,
|
||||
"total_comments": 0,
|
||||
"was_liked_by_me": false,
|
||||
"is_favorite": false,
|
||||
"daily_nutrition": [
|
||||
{
|
||||
"energy": 603.0,
|
||||
"proteins": 56.2,
|
||||
"fats": 36.2,
|
||||
"carbohydrates": 10.0
|
||||
},
|
||||
{
|
||||
"energy": 226.0,
|
||||
"proteins": 31.0,
|
||||
"fats": 9.0,
|
||||
"carbohydrates": 3.4
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"links": {
|
||||
"first": "http://localhost/api/my-diets?page=1",
|
||||
"last": "http://localhost/api/my-diets?page=1",
|
||||
"prev": null,
|
||||
"next": null
|
||||
},
|
||||
"meta": {
|
||||
"current_page": 1,
|
||||
"from": 1,
|
||||
"last_page": 1,
|
||||
"links": [],
|
||||
"path": "http://localhost/api/my-diets",
|
||||
"per_page": 10,
|
||||
"to": 1,
|
||||
"total": 1,
|
||||
"total_min_price": null,
|
||||
"total_max_price": null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user