diff --git a/frontend/src/app/components/recipe-details/recipe-details.component.spec.ts b/frontend/src/app/components/recipe-details/recipe-details.component.spec.ts index b9705056..1eca26fe 100644 --- a/frontend/src/app/components/recipe-details/recipe-details.component.spec.ts +++ b/frontend/src/app/components/recipe-details/recipe-details.component.spec.ts @@ -2,19 +2,34 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { IonicModule } from '@ionic/angular'; import { RecipeDetailsComponent } from './recipe-details.component'; +import { MealI } from '../../models/meal.model'; describe('RecipeDetailsComponent', () => { let component: RecipeDetailsComponent; let fixture: ComponentFixture; + let mockItem: MealI; + let mockItems: MealI[]; beforeEach(waitForAsync(() => { + mockItem = { + name: 'test', + description: 'test', + ingredients: 'test', + instructions: 'test', + image: 'test', + cookingTime: 'test', + }; + + mockItems = [mockItem]; + TestBed.configureTestingModule({ - declarations: [ RecipeDetailsComponent ], - imports: [IonicModule.forRoot()] + imports: [IonicModule.forRoot(), RecipeDetailsComponent], }).compileComponents(); fixture = TestBed.createComponent(RecipeDetailsComponent); component = fixture.componentInstance; + component.item = mockItem; + component.items = mockItems; fixture.detectChanges(); })); diff --git a/frontend/src/app/pages/recipe-book/recipe-book.page.spec.ts b/frontend/src/app/pages/recipe-book/recipe-book.page.spec.ts index 161d8a6c..0fc54835 100644 --- a/frontend/src/app/pages/recipe-book/recipe-book.page.spec.ts +++ b/frontend/src/app/pages/recipe-book/recipe-book.page.spec.ts @@ -1,17 +1,19 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RecipeBookPage } from './recipe-book.page'; -import { MealGenerationService } from '../../services/meal-generation/meal-generation.service'; +import { AuthenticationService, RecipeBookApiService } from '../../services/services'; describe('RecipeBookPage', () => { let component: RecipeBookPage; let fixture: ComponentFixture; - let mockMealGenerationService: jasmine.SpyObj; + let mockRecipeBookApiService: jasmine.SpyObj; + let authServiceSpy: jasmine.SpyObj; beforeEach(async() => { await TestBed.configureTestingModule({ imports: [RecipeBookPage], providers: [ - { provide: MealGenerationService, useValue: mockMealGenerationService }, + { provide: RecipeBookApiService, useValue: mockRecipeBookApiService }, + { provide: AuthenticationService, useValue: authServiceSpy }, ], }).compileComponents(); fixture = TestBed.createComponent(RecipeBookPage); diff --git a/frontend/src/app/services/recipe-book/add-recipe.service.spec.ts b/frontend/src/app/services/recipe-book/add-recipe.service.spec.ts index e99e2766..744e936c 100644 --- a/frontend/src/app/services/recipe-book/add-recipe.service.spec.ts +++ b/frontend/src/app/services/recipe-book/add-recipe.service.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { AddRecipeService } from '../add-recipe.service'; +import { AddRecipeService } from './add-recipe.service'; describe('AddRecipeService', () => { let service: AddRecipeService; diff --git a/frontend/src/app/services/recipe-book/recipe-book-api.service.spec.ts b/frontend/src/app/services/recipe-book/recipe-book-api.service.spec.ts index 748a5616..8636c936 100644 --- a/frontend/src/app/services/recipe-book/recipe-book-api.service.spec.ts +++ b/frontend/src/app/services/recipe-book/recipe-book-api.service.spec.ts @@ -1,13 +1,15 @@ import { TestBed } from '@angular/core/testing'; import { RecipeBookApiService } from './recipe-book-api.service'; +import { HttpClient } from '@angular/common/http'; describe('RecipeBookApiService', () => { let service: RecipeBookApiService; + let httpClientSpy: jasmine.SpyObj; beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(RecipeBookApiService); + httpClientSpy = jasmine.createSpyObj('HttpClient', ['post']); + service = new RecipeBookApiService(httpClientSpy as any); }); it('should be created', () => {