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