diff --git a/app/recipe/tests/test_recipe_api.py b/app/recipe/tests/test_recipe_api.py index 781fc50..0841bc5 100644 --- a/app/recipe/tests/test_recipe_api.py +++ b/app/recipe/tests/test_recipe_api.py @@ -358,3 +358,18 @@ def test_update_recipe_assign_ingredient(self): self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertIn(ingredient, recipe.ingredients.all()) + + def test_clear_recipe_ingredients(self): + ingredient = Ingredient.objects.create(user=self.user, name='Shrimp') + recipe = create_recipe(user=self.user) + recipe.ingredients.add(ingredient) + + payload = { + 'ingredients': [] + } + + url = detail_url(recipe.id) + res = self.client.patch(url, payload, format='json') + + self.assertEqual(res.status_code, status.HTTP_200_OK) + self.assertEqual(recipe.ingredients.count(), 0)