diff --git a/LeftOvers/Services/Profiles/ProfileService.ts b/LeftOvers/Services/Profiles/ProfileService.ts index 30646bf..448f67b 100644 --- a/LeftOvers/Services/Profiles/ProfileService.ts +++ b/LeftOvers/Services/Profiles/ProfileService.ts @@ -1,19 +1,19 @@ -import Profil from "../../Models/Profil"; +import Profile from "../../Models/Profile"; import IProfileService from "./IProfileService"; import AsyncStorage from "@react-native-async-storage/async-storage"; export default class ProfileService implements IProfileService { - async getProfiles(): Promise { + async getProfiles(): Promise { const results = await AsyncStorage.getItem('profiles'); const tmp = JSON.parse(results) - let existingProfiles: Profil[] = [] + let existingProfiles: Profile[] = [] for (let item of tmp) { - existingProfiles.push(new Profil(item._name, item._avatar, item._allergy, item._diets)) + existingProfiles.push(new Profile(item._name, item._avatar, item._allergy, item._diets)) } return existingProfiles; } - async addProfile(new_profile : Profil): Promise { + async addProfile(new_profile : Profile): Promise { const existingProfiles = await this.getProfiles() for (let current_profile of existingProfiles) { if (current_profile.name == new_profile.name) { diff --git a/LeftOvers/__tests__/IngredientsServices.test.ts b/LeftOvers/__tests__/IngredientsServices.test.ts index 7d07da2..d180d1f 100644 --- a/LeftOvers/__tests__/IngredientsServices.test.ts +++ b/LeftOvers/__tests__/IngredientsServices.test.ts @@ -29,7 +29,7 @@ describe('IngredientService', () => { const result = await ingredient_service.getfilteredIngredient('car') let test = true for (let ingredient of result) { - if (ingredient.name.includes('car')) { + if (!ingredient.name.includes('car')) { test = false } } diff --git a/LeftOvers/__tests__/ProfileService.test.ts b/LeftOvers/__tests__/ProfileService.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/LeftOvers/__tests__/RecipesService.test.ts b/LeftOvers/__tests__/RecipesService.test.ts new file mode 100644 index 0000000..8e0b50f --- /dev/null +++ b/LeftOvers/__tests__/RecipesService.test.ts @@ -0,0 +1,22 @@ +import RecipesService from '../Services/Recipes/RecipesServices'; + +describe('RecipesService', () => { + const recipe_service = new RecipesService(); + + it('should get one recipe', async () => { + const result = await recipe_service.getRecipeById(4444) + expect(result.id).toBe(4444); + }); + + it('should get all recipes', async () => { + const result = await recipe_service.getAllRecipes() + const test = result.length >= 1 + expect(test).toBe(true); + }, 120000); + + it('should get one recipe', async () => { + const result = await recipe_service.getRecipeWithIngredients(['1928:2148:2809:2853:3723:6261:6335:7076']) + const test = result.length >= 1 + expect(test).toBe(true); + }); +}); \ No newline at end of file