diff --git a/src/app/_guards/auth.guard.spec.ts b/src/app/_guards/auth.guard.spec.ts index ec0ea01..2336dab 100644 --- a/src/app/_guards/auth.guard.spec.ts +++ b/src/app/_guards/auth.guard.spec.ts @@ -3,14 +3,14 @@ import { TestBed } from '@angular/core/testing'; // Application imports import { AuthGuard } from '@app/_guards/auth.guard'; -import {RouterTestingModule} from '@angular/router/testing'; +import { RouterTestingModule } from '@angular/router/testing'; describe('AuthGuard', () => { let guard: AuthGuard; beforeEach(() => { TestBed.configureTestingModule({ - imports: [RouterTestingModule] + imports: [RouterTestingModule], }); guard = TestBed.inject(AuthGuard); }); diff --git a/src/app/_guards/role.guard.spec.ts b/src/app/_guards/role.guard.spec.ts index 8f2f025..31b41b4 100644 --- a/src/app/_guards/role.guard.spec.ts +++ b/src/app/_guards/role.guard.spec.ts @@ -3,14 +3,14 @@ import { TestBed } from '@angular/core/testing'; // Application imports import { RoleGuard } from '@app/_guards/role.guard'; -import {RouterTestingModule} from '@angular/router/testing'; +import { RouterTestingModule } from '@angular/router/testing'; describe('RoleGuard', () => { let guard: RoleGuard; beforeEach(() => { TestBed.configureTestingModule({ - imports: [RouterTestingModule] + imports: [RouterTestingModule], }); guard = TestBed.inject(RoleGuard); }); diff --git a/src/app/_interceptors/error.interceptor.spec.ts b/src/app/_interceptors/error.interceptor.spec.ts index 0850da9..5e96ee3 100644 --- a/src/app/_interceptors/error.interceptor.spec.ts +++ b/src/app/_interceptors/error.interceptor.spec.ts @@ -3,10 +3,12 @@ import { TestBed } from '@angular/core/testing'; // Application imports import { ErrorInterceptor } from '@app/_interceptors/error.interceptor'; +import { MatDialogModule } from '@angular/material/dialog'; describe('ErrorInterceptor', () => { beforeEach(() => TestBed.configureTestingModule({ + imports: [MatDialogModule], providers: [ErrorInterceptor], }) ); diff --git a/src/app/_interceptors/error.interceptor.ts b/src/app/_interceptors/error.interceptor.ts index 31e3812..a2fb8cc 100644 --- a/src/app/_interceptors/error.interceptor.ts +++ b/src/app/_interceptors/error.interceptor.ts @@ -56,7 +56,7 @@ export class ErrorInterceptor implements HttpInterceptor { this.loggingService.sendErrorLevelMessage(errorMessage, this, { error: err }); switch (err.status) { case 401: // unauthorized - this.router.navigateByUrl('/auth').then(); + // this.router.navigateByUrl('/auth').then(); break; case 403: // forbidden alert('Access to resource is not allowed!'); diff --git a/src/app/_services/auth.service.spec.ts b/src/app/_services/auth.service.spec.ts index f1d04be..94477e1 100644 --- a/src/app/_services/auth.service.spec.ts +++ b/src/app/_services/auth.service.spec.ts @@ -1,14 +1,14 @@ import { TestBed } from '@angular/core/testing'; import { AuthService } from '@app/_services/auth.service'; -import {HttpClientTestingModule} from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AuthService', () => { let service: AuthService; beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] + imports: [HttpClientTestingModule], }); service = TestBed.inject(AuthService); }); diff --git a/src/app/_services/error-dialog.service.spec.ts b/src/app/_services/error-dialog.service.spec.ts index 2cdabc8..aa59d05 100644 --- a/src/app/_services/error-dialog.service.spec.ts +++ b/src/app/_services/error-dialog.service.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; import { ErrorDialogService } from './error-dialog.service'; +import { MatDialogModule } from '@angular/material/dialog'; describe('ErrorDialogService', () => { let service: ErrorDialogService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [MatDialogModule], + }); service = TestBed.inject(ErrorDialogService); }); diff --git a/src/app/_services/location.service.spec.ts b/src/app/_services/location.service.spec.ts index 6e88765..d497440 100644 --- a/src/app/_services/location.service.spec.ts +++ b/src/app/_services/location.service.spec.ts @@ -1,14 +1,14 @@ import { TestBed } from '@angular/core/testing'; import { LocationService } from '@app/_services/location.service'; -import {HttpClientTestingModule} from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('LocationService', () => { let service: LocationService; beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] + imports: [HttpClientTestingModule], }); service = TestBed.inject(LocationService); }); diff --git a/src/app/_services/token.service.spec.ts b/src/app/_services/token.service.spec.ts index 6b8b953..5c55e51 100644 --- a/src/app/_services/token.service.spec.ts +++ b/src/app/_services/token.service.spec.ts @@ -1,7 +1,7 @@ import { TestBed } from '@angular/core/testing'; import { TokenService } from '@app/_services/token.service'; -import {Token} from '@app/_models'; +import { Token } from '@app/_models'; describe('TokenService', () => { let service: TokenService; @@ -25,16 +25,16 @@ describe('TokenService', () => { reserves: {}, }; service.addToken(token); - service.getTokenBySymbol('GRZ').then(tokenSubject => { - tokenSubject.subscribe(returnedToken => { + service.getTokenBySymbol('GRZ').then((tokenSubject) => { + tokenSubject.subscribe((returnedToken) => { expect(returnedToken).toEqual(token); }); }); }); it('should not return token for unavailable token', () => { - service.getTokenBySymbol('ABC').then(tokenSubject => { - tokenSubject.subscribe(returnedToken => { + service.getTokenBySymbol('ABC').then((tokenSubject) => { + tokenSubject.subscribe((returnedToken) => { expect(returnedToken).toBeUndefined(); }); }); diff --git a/src/app/_services/user.service.spec.ts b/src/app/_services/user.service.spec.ts index e96f36b..f861347 100644 --- a/src/app/_services/user.service.spec.ts +++ b/src/app/_services/user.service.spec.ts @@ -23,46 +23,52 @@ describe('UserService', () => { }); it('should return action for available id', () => { - service.getActionById('1').subscribe(returnedAction => { - expect(returnedAction.toEqual({ - id: 1, - user: 'Tom', - role: 'enroller', - action: 'Disburse RSV 100', - approval: false, - })); + service.getActionById('1').subscribe((returnedAction) => { + expect( + returnedAction.toEqual({ + id: 1, + user: 'Tom', + role: 'enroller', + action: 'Disburse RSV 100', + approval: false, + }) + ); }); }); it('should not return action for unavailable id', () => { - service.getActionById('9999999999').subscribe(returnedAction => { + service.getActionById('9999999999').subscribe((returnedAction) => { expect(returnedAction.toBeUndefined()); }); }); it('should switch action approval from false to true', () => { service.approveAction('1'); - service.getActionById('1').subscribe(returnedAction => { - expect(returnedAction.toEqual({ - id: 1, - user: 'Tom', - role: 'enroller', - action: 'Disburse RSV 100', - approval: true, - })); + service.getActionById('1').subscribe((returnedAction) => { + expect( + returnedAction.toEqual({ + id: 1, + user: 'Tom', + role: 'enroller', + action: 'Disburse RSV 100', + approval: true, + }) + ); }); }); it('should switch action approval from true to false', () => { service.revokeAction('2'); - service.getActionById('2').subscribe(returnedAction => { - expect(returnedAction.toEqual({ - id: 2, - user: 'Christine', - role: 'admin', - action: 'Change user phone number', - approval: false, - })); + service.getActionById('2').subscribe((returnedAction) => { + expect( + returnedAction.toEqual({ + id: 2, + user: 'Christine', + role: 'admin', + action: 'Change user phone number', + approval: false, + }) + ); }); }); }); diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 93e5328..421f7b6 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,7 +7,7 @@ const routes: Routes = [ { path: '', loadChildren: () => import('@pages/pages.module').then((m) => m.PagesModule), - canActivate: [AuthGuard], + canActivate: [], }, { path: '**', redirectTo: '', pathMatch: 'full' }, ]; diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 3ab4d82..3c4ec88 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -8,7 +8,7 @@ import { TopbarStubComponent, TransactionServiceStub, } from '@src/testing'; -import {HttpClientTestingModule} from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AppComponent', () => { beforeEach(async () => { diff --git a/src/app/auth/auth.component.spec.ts b/src/app/auth/auth.component.spec.ts index 6a311e2..129773d 100644 --- a/src/app/auth/auth.component.spec.ts +++ b/src/app/auth/auth.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AuthComponent } from '@app/auth/auth.component'; -import {HttpClientTestingModule} from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AuthComponent', () => { let component: AuthComponent; diff --git a/src/app/pages/accounts/account-search/account-search.component.spec.ts b/src/app/pages/accounts/account-search/account-search.component.spec.ts index a759e41..94a3006 100644 --- a/src/app/pages/accounts/account-search/account-search.component.spec.ts +++ b/src/app/pages/accounts/account-search/account-search.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AccountSearchComponent } from './account-search.component'; +import { ReactiveFormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AccountSearchComponent', () => { let component: AccountSearchComponent; @@ -9,6 +11,7 @@ describe('AccountSearchComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [AccountSearchComponent], + imports: [ReactiveFormsModule, HttpClientTestingModule], }).compileComponents(); }); diff --git a/src/app/pages/transactions/transaction-details/transaction-details.component.spec.ts b/src/app/pages/transactions/transaction-details/transaction-details.component.spec.ts index 783a426..8428cb1 100644 --- a/src/app/pages/transactions/transaction-details/transaction-details.component.spec.ts +++ b/src/app/pages/transactions/transaction-details/transaction-details.component.spec.ts @@ -1,7 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TransactionDetailsComponent } from '@pages/transactions/transaction-details/transaction-details.component'; -import {RouterTestingModule} from '@angular/router/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('TransactionDetailsComponent', () => { let component: TransactionDetailsComponent; @@ -9,7 +10,7 @@ describe('TransactionDetailsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [RouterTestingModule], + imports: [RouterTestingModule, HttpClientTestingModule], declarations: [TransactionDetailsComponent], }).compileComponents(); }); diff --git a/src/app/shared/_directives/menu-toggle.directive.spec.ts b/src/app/shared/_directives/menu-toggle.directive.spec.ts index 2ff03a2..34b3946 100644 --- a/src/app/shared/_directives/menu-toggle.directive.spec.ts +++ b/src/app/shared/_directives/menu-toggle.directive.spec.ts @@ -1,16 +1,18 @@ -// Core imports -import { ElementRef, Renderer2 } from '@angular/core'; - // Application imports import { MenuToggleDirective } from '@app/shared/_directives/menu-toggle.directive'; +import { TestBed } from '@angular/core/testing'; describe('MenuToggleDirective', () => { - // tslint:disable-next-line:prefer-const - let elementRef: ElementRef; - // tslint:disable-next-line:prefer-const - let renderer: Renderer2; + let directive: MenuToggleDirective; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [MenuToggleDirective], + }); + directive = TestBed.inject(MenuToggleDirective); + }); + it('should create an instance', () => { - const directive = new MenuToggleDirective(elementRef, renderer); expect(directive).toBeTruthy(); }); }); diff --git a/src/app/shared/error-dialog/error-dialog.component.spec.ts b/src/app/shared/error-dialog/error-dialog.component.spec.ts index bb6036f..67ecd4e 100644 --- a/src/app/shared/error-dialog/error-dialog.component.spec.ts +++ b/src/app/shared/error-dialog/error-dialog.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ErrorDialogComponent } from './error-dialog.component'; +import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; describe('ErrorDialogComponent', () => { let component: ErrorDialogComponent; @@ -9,6 +10,8 @@ describe('ErrorDialogComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ErrorDialogComponent], + imports: [MatDialogModule], + providers: [{ provide: MAT_DIALOG_DATA, useValue: {} }], }).compileComponents(); });