fixing tests.

This commit is contained in:
Jason Kulatunga 2022-10-13 23:20:43 -07:00
parent e5769eb731
commit 4cb8a23794
13 changed files with 64 additions and 17 deletions

View File

@ -25,11 +25,4 @@ describe('AppComponent', () => {
const app = fixture.componentInstance;
expect(app.title).toEqual('fastenhealth');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('fastenhealth app is running!');
});
});

View File

@ -1,6 +1,9 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterModule} from '@angular/router';
import {RouterTestingModule} from '@angular/router/testing';
describe('HeaderComponent', () => {
let component: HeaderComponent;
@ -8,6 +11,7 @@ describe('HeaderComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ HttpClientTestingModule, RouterTestingModule, RouterModule ],
declarations: [ HeaderComponent ]
})
.compileComponents();

View File

@ -1,6 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ResourceListComponent } from './resource-list.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {ResourceListOutletDirective} from './resource-list-outlet.directive';
describe('ResourceListComponent', () => {
let component: ResourceListComponent;
@ -8,7 +10,8 @@ describe('ResourceListComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ResourceListComponent ]
imports: [HttpClientTestingModule],
declarations: [ ResourceListComponent, ResourceListOutletDirective ]
})
.compileComponents();

View File

@ -1,6 +1,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthSigninComponent } from './auth-signin.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {RouterModule} from '@angular/router';
import {FormsModule} from '@angular/forms';
describe('AuthSigninComponent', () => {
let component: AuthSigninComponent;
@ -8,7 +12,8 @@ describe('AuthSigninComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AuthSigninComponent ]
declarations: [ AuthSigninComponent ],
imports: [HttpClientTestingModule, FormsModule],
})
.compileComponents();

View File

@ -1,6 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthSignupComponent } from './auth-signup.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {FormsModule} from '@angular/forms';
describe('AuthSignupComponent', () => {
let component: AuthSignupComponent;
@ -8,7 +10,8 @@ describe('AuthSignupComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AuthSignupComponent ]
declarations: [ AuthSignupComponent ],
imports: [HttpClientTestingModule, FormsModule],
})
.compileComponents();

View File

@ -1,6 +1,9 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardComponent } from './dashboard.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {RouterModule} from '@angular/router';
describe('DashboardComponent', () => {
let component: DashboardComponent;
@ -8,6 +11,7 @@ describe('DashboardComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule, RouterModule],
declarations: [ DashboardComponent ]
})
.compileComponents();

View File

@ -1,6 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MedicalSourcesComponent } from './medical-sources.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
describe('MedicalSourcesComponent', () => {
let component: MedicalSourcesComponent;
@ -8,7 +10,8 @@ describe('MedicalSourcesComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MedicalSourcesComponent ]
declarations: [ MedicalSourcesComponent ],
imports: [HttpClientTestingModule, RouterTestingModule],
})
.compileComponents();

View File

@ -1,6 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ResourceDetailComponent } from './resource-detail.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {ActivatedRoute, convertToParamMap} from '@angular/router';
describe('ResourceDetailComponent', () => {
let component: ResourceDetailComponent;
@ -8,7 +11,14 @@ describe('ResourceDetailComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ResourceDetailComponent ]
declarations: [ ResourceDetailComponent ],
imports: [HttpClientTestingModule, RouterTestingModule],
providers: [
{
provide: ActivatedRoute,
useValue: {snapshot: {paramMap: convertToParamMap( { 'resource_id': '1234' } )}}
}
]
})
.compileComponents();

View File

@ -1,6 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SourceDetailComponent } from './source-detail.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {ActivatedRoute, convertToParamMap, RouterModule} from '@angular/router';
describe('SourceDetailComponent', () => {
let component: SourceDetailComponent;
@ -8,7 +11,14 @@ describe('SourceDetailComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SourceDetailComponent ]
imports: [HttpClientTestingModule, RouterTestingModule, RouterModule],
declarations: [ SourceDetailComponent ],
providers: [
{
provide: ActivatedRoute,
useValue: {snapshot: {paramMap: convertToParamMap( { 'source_id': '1234' } )}}
}
]
})
.compileComponents();

View File

@ -22,7 +22,7 @@ export class SourceDetailComponent implements OnInit {
constructor(private fastenDb: FastenDbService, private router: Router, private route: ActivatedRoute) {
//check if the current Source was sent over using the router state storage:
if(this.router.getCurrentNavigation().extras.state){
if(this.router.getCurrentNavigation()?.extras?.state){
this.selectedSource = this.router.getCurrentNavigation().extras.state as Source
}
}

View File

@ -1,12 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { FastenApiService } from './fasten-api.service';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('FastenApiService', () => {
let service: FastenApiService;
beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [ HttpClientTestingModule ],
});
service = TestBed.inject(FastenApiService);
});

View File

@ -1,12 +1,15 @@
import { TestBed } from '@angular/core/testing';
import { FastenDbService } from './fasten-db.service';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('FastenDbService', () => {
let service: FastenDbService;
beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});
service = TestBed.inject(FastenDbService);
});

View File

@ -1,12 +1,17 @@
import { TestBed } from '@angular/core/testing';
import { LighthouseService } from './lighthouse.service';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {RouterModule} from '@angular/router';
describe('LighthouseService', () => {
let service: LighthouseService;
beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});
service = TestBed.inject(LighthouseService);
});