feat: ingredientds

This commit is contained in:
2026-05-18 14:51:25 +02:00
parent 7a907f2b17
commit 8c612452f2
8 changed files with 50 additions and 4 deletions
+13
View File
@@ -23,11 +23,13 @@ it('creates a meal post with ingredients', function () {
[
'position' => 1,
'ingredient' => 'Riz',
'quantity' => 150,
'unit' => IngredientUnit::GRAM->value,
],
[
'position' => 2,
'ingredient' => 'Saumon',
'quantity' => 120,
'unit' => IngredientUnit::GRAM->value,
],
],
@@ -36,6 +38,7 @@ it('creates a meal post with ingredients', function () {
$response
->assertCreated()
->assertJsonPath('data.ingredients.0.ingredient', 'Riz')
->assertJsonPath('data.ingredients.0.quantity', 150)
->assertJsonPath('data.ingredients.0.unit', IngredientUnit::GRAM->value)
->assertJsonPath('data.ingredients.1.ingredient', 'Saumon');
@@ -43,6 +46,7 @@ it('creates a meal post with ingredients', function () {
'meal_posts_id' => $response->json('data.id'),
'position' => 1,
'ingredient' => 'Riz',
'quantity' => 150,
'unit' => IngredientUnit::GRAM->value,
]);
});
@@ -59,6 +63,7 @@ it('validates meal post ingredients', function () {
[
'position' => -1,
'ingredient' => '',
'quantity' => 0,
'unit' => 'cup',
],
],
@@ -69,6 +74,7 @@ it('validates meal post ingredients', function () {
->assertJsonValidationErrors([
'ingredients.0.position',
'ingredients.0.ingredient',
'ingredients.0.quantity',
'ingredients.0.unit',
]);
});
@@ -80,11 +86,13 @@ it('replaces meal post ingredients when updating a meal post', function () {
[
'position' => 1,
'ingredient' => 'Riz',
'quantity' => 150,
'unit' => IngredientUnit::GRAM,
],
[
'position' => 2,
'ingredient' => 'Saumon',
'quantity' => 120,
'unit' => IngredientUnit::GRAM,
],
]);
@@ -96,11 +104,13 @@ it('replaces meal post ingredients when updating a meal post', function () {
[
'position' => 1,
'ingredient' => 'Pates',
'quantity' => 200,
'unit' => IngredientUnit::GRAM->value,
],
[
'position' => 2,
'ingredient' => 'Huile olive',
'quantity' => 1,
'unit' => IngredientUnit::TABLESPOON->value,
],
],
@@ -119,6 +129,7 @@ it('replaces meal post ingredients when updating a meal post', function () {
'meal_posts_id' => $mealPost->id,
'position' => 1,
'ingredient' => 'Pates',
'quantity' => 200,
'unit' => IngredientUnit::GRAM->value,
]);
});
@@ -131,6 +142,7 @@ it('keeps existing ingredients when updating a meal post without ingredients', f
$mealPost->ingredients()->create([
'position' => 1,
'ingredient' => 'Riz',
'quantity' => 150,
'unit' => IngredientUnit::GRAM,
]);
@@ -157,6 +169,7 @@ it('removes meal post ingredients when updating with an empty ingredients list',
$mealPost->ingredients()->create([
'position' => 1,
'ingredient' => 'Riz',
'quantity' => 150,
'unit' => IngredientUnit::GRAM,
]);