From 1b62198edb32700d57b4957a85242818ec657191 Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 17 Sep 2021 15:50:57 +0300 Subject: [PATCH] Fixing default tests --- .../src/app/guard/authentication.guard.spec.ts | 14 +++++++++++++- .../src/app/service/authentication.service.spec.ts | 8 +++++++- .../src/app/service/user.service.spec.ts | 7 ++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/support-portal-frontend/src/app/guard/authentication.guard.spec.ts b/support-portal-frontend/src/app/guard/authentication.guard.spec.ts index 63b7a1c..d7386c4 100644 --- a/support-portal-frontend/src/app/guard/authentication.guard.spec.ts +++ b/support-portal-frontend/src/app/guard/authentication.guard.spec.ts @@ -1,12 +1,24 @@ import {TestBed} from '@angular/core/testing'; import {AuthenticationGuard} from './authentication.guard'; +import {HttpClient} from "@angular/common/http"; +import {NotificationModule} from "../notification/notification.module"; +import {RouterTestingModule} from "@angular/router/testing"; describe('AuthenticationGuard', () => { let guard: AuthenticationGuard; beforeEach(() => { - TestBed.configureTestingModule({}); + + let httpClientSpy = jasmine.createSpyObj('HttpClient', ['']); + + TestBed.configureTestingModule({ + imports: [NotificationModule, RouterTestingModule.withRoutes([])], + providers: [ + {provide: HttpClient, useValue: httpClientSpy} + ] + }); + guard = TestBed.inject(AuthenticationGuard); }); diff --git a/support-portal-frontend/src/app/service/authentication.service.spec.ts b/support-portal-frontend/src/app/service/authentication.service.spec.ts index 8b96259..3781eda 100644 --- a/support-portal-frontend/src/app/service/authentication.service.spec.ts +++ b/support-portal-frontend/src/app/service/authentication.service.spec.ts @@ -1,12 +1,18 @@ import {TestBed} from '@angular/core/testing'; import {AuthenticationService} from './authentication.service'; +import {HttpClient} from "@angular/common/http"; describe('AuthenticationService', () => { let service: AuthenticationService; beforeEach(() => { - TestBed.configureTestingModule({}); + + let httpClientSpy = jasmine.createSpyObj('HttpClient', ['']); + + TestBed.configureTestingModule({ + providers: [{provide: HttpClient, useValue: httpClientSpy}] + }); service = TestBed.inject(AuthenticationService); }); diff --git a/support-portal-frontend/src/app/service/user.service.spec.ts b/support-portal-frontend/src/app/service/user.service.spec.ts index ad743a7..a8b2602 100644 --- a/support-portal-frontend/src/app/service/user.service.spec.ts +++ b/support-portal-frontend/src/app/service/user.service.spec.ts @@ -1,12 +1,17 @@ import {TestBed} from '@angular/core/testing'; import {UserService} from './user.service'; +import {HttpClient} from "@angular/common/http"; describe('UserService', () => { let service: UserService; beforeEach(() => { - TestBed.configureTestingModule({}); + let httpClientSpy = jasmine.createSpyObj('HttpClient', ['']); + + TestBed.configureTestingModule({ + providers: [{provide: HttpClient, useValue: httpClientSpy}] + }); service = TestBed.inject(UserService); });