Skip to content

Commit

Permalink
🐛 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SkulderLock committed Aug 1, 2023
1 parent d16d0e2 commit 69a2ab9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecipeDetailsComponent>;
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();
}));

Expand Down
8 changes: 5 additions & 3 deletions frontend/src/app/pages/recipe-book/recipe-book.page.spec.ts
Original file line number Diff line number Diff line change
@@ -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<RecipeBookPage>;
let mockMealGenerationService: jasmine.SpyObj<MealGenerationService>;
let mockRecipeBookApiService: jasmine.SpyObj<RecipeBookApiService>;
let authServiceSpy: jasmine.SpyObj<AuthenticationService>;

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<HttpClient>;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(RecipeBookApiService);
httpClientSpy = jasmine.createSpyObj('HttpClient', ['post']);
service = new RecipeBookApiService(httpClientSpy as any);
});

it('should be created', () => {
Expand Down

0 comments on commit 69a2ab9

Please sign in to comment.