Add HttpClient and Router testing modules to test.
This commit is contained in:
parent
7e93aea96f
commit
78a8558882
@ -100,5 +100,9 @@
|
||||
"hooks": {
|
||||
"pre-commit": "npx pretty-quick --staged && npm run format:lint && npx lint-staged"
|
||||
}
|
||||
},
|
||||
"browser": {
|
||||
"child_process": false,
|
||||
"fs": false
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,15 @@ import { TestBed } from '@angular/core/testing';
|
||||
|
||||
// Application imports
|
||||
import { AuthGuard } from '@app/_guards/auth.guard';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
|
||||
describe('AuthGuard', () => {
|
||||
let guard: AuthGuard;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule]
|
||||
});
|
||||
guard = TestBed.inject(AuthGuard);
|
||||
});
|
||||
|
||||
|
@ -3,12 +3,15 @@ import { TestBed } from '@angular/core/testing';
|
||||
|
||||
// Application imports
|
||||
import { RoleGuard } from '@app/_guards/role.guard';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
|
||||
describe('RoleGuard', () => {
|
||||
let guard: RoleGuard;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule]
|
||||
});
|
||||
guard = TestBed.inject(RoleGuard);
|
||||
});
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthService } from '@app/_services/auth.service';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule]
|
||||
});
|
||||
service = TestBed.inject(AuthService);
|
||||
});
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LocationService } from '@app/_services/location.service';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
|
||||
describe('LocationService', () => {
|
||||
let service: LocationService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule]
|
||||
});
|
||||
service = TestBed.inject(LocationService);
|
||||
});
|
||||
|
||||
|
@ -8,11 +8,12 @@ import {
|
||||
TopbarStubComponent,
|
||||
TransactionServiceStub,
|
||||
} from '@src/testing';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule],
|
||||
imports: [HttpClientTestingModule, RouterTestingModule],
|
||||
declarations: [AppComponent, FooterStubComponent, SidebarStubComponent, TopbarStubComponent],
|
||||
providers: [{ provide: TransactionService, useClass: TransactionServiceStub }],
|
||||
}).compileComponents();
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthComponent } from '@app/auth/auth.component';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
|
||||
describe('AuthComponent', () => {
|
||||
let component: AuthComponent;
|
||||
@ -8,6 +9,7 @@ describe('AuthComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule],
|
||||
declarations: [AuthComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ describe('AdminComponent', () => {
|
||||
|
||||
it('#approveAction should toggle approval status', () => {
|
||||
const action = userService.getActionById('1');
|
||||
expect(action).toBe({
|
||||
expect(action).toEqual({
|
||||
id: 1,
|
||||
user: 'Tom',
|
||||
role: 'enroller',
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TransactionDetailsComponent } from '@pages/transactions/transaction-details/transaction-details.component';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
|
||||
describe('TransactionDetailsComponent', () => {
|
||||
let component: TransactionDetailsComponent;
|
||||
@ -8,6 +9,7 @@ describe('TransactionDetailsComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule],
|
||||
declarations: [TransactionDetailsComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user