From a761314e5837e558dbebde7dde330c1db765e5b4 Mon Sep 17 00:00:00 2001 From: Remi REGNAULT Date: Fri, 8 Dec 2023 15:20:57 +0100 Subject: [PATCH] tests: add tests for IngredientsServices --- .../__tests__/IngredientsServices.test.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/LeftOvers/__tests__/IngredientsServices.test.ts b/LeftOvers/__tests__/IngredientsServices.test.ts index e423164..7d07da2 100644 --- a/LeftOvers/__tests__/IngredientsServices.test.ts +++ b/LeftOvers/__tests__/IngredientsServices.test.ts @@ -4,8 +4,35 @@ describe('IngredientService', () => { const ingredient_service = new IngredientService(); it('should get one ingredient', async () => { - const ingredient_service = new IngredientService(); const result = await ingredient_service.getIngredientById(1) expect(result.id).toBe(1); }); + + it('should get all ingredients', async () => { + const result = await ingredient_service.getAllIngredient() + const test = result.length >= 1 + expect(test).toBe(true); + }); + + it('should return several ingredients starting by letter a', async () => { + const result = await ingredient_service.getIngredientByLetter('a') + let test = true + for (let ingredient of result) { + if (ingredient.name[0] !== 'a') { + test = false + } + } + expect(test).toBe(true); + }); + + it('should return several ingredients with car in the name', async () => { + const result = await ingredient_service.getfilteredIngredient('car') + let test = true + for (let ingredient of result) { + if (ingredient.name.includes('car')) { + test = false + } + } + expect(test).toBe(true); + }); }); \ No newline at end of file