diff --git a/src/components/Recipes/Ingredients/RecipeIngredient.jsx b/src/components/Recipes/Ingredients/RecipeIngredient.jsx index d8d59ba..3bcd006 100644 --- a/src/components/Recipes/Ingredients/RecipeIngredient.jsx +++ b/src/components/Recipes/Ingredients/RecipeIngredient.jsx @@ -14,7 +14,16 @@ export default function RecipeIngredient({ ingredient }) { {ingredient.food}

- {`${ingredient.quantity} ${ingredient.measure}`} + + {ingredient.quantity > 0 + ? parseFloat(ingredient.quantity).toFixed(1) + " " + : null} + + + {ingredient.measure !== "null" && ingredient.measure !== "" + ? ingredient.measure + : null} + {`(${Math.round( ingredient.weight, )} g)`} diff --git a/src/components/Recipes/Ingredients/RecipeIngredient.test.jsx b/src/components/Recipes/Ingredients/RecipeIngredient.test.jsx index 58a6899..cda682c 100644 --- a/src/components/Recipes/Ingredients/RecipeIngredient.test.jsx +++ b/src/components/Recipes/Ingredients/RecipeIngredient.test.jsx @@ -40,8 +40,10 @@ describe("RecipeIngredient component", () => { text: "A fresh apple", }; render(); - const quantityMeasureElement = screen.getByText(/1 piece/i); + const quantityMeasureElement = screen.getAllByText(/1.0/i)[0]; + const unitMeasureElement = screen.getByText(/piece/i); expect(quantityMeasureElement).toBeInTheDocument(); + expect(unitMeasureElement).toBeInTheDocument(); }); it("renders the ingredient weight correctly", () => {