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; const app = fixture.componentInstance;
expect(app.title).toEqual('fastenhealth'); 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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component'; 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', () => { describe('HeaderComponent', () => {
let component: HeaderComponent; let component: HeaderComponent;
@ -8,6 +11,7 @@ describe('HeaderComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ HttpClientTestingModule, RouterTestingModule, RouterModule ],
declarations: [ HeaderComponent ] declarations: [ HeaderComponent ]
}) })
.compileComponents(); .compileComponents();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,17 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { LighthouseService } from './lighthouse.service'; 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', () => { describe('LighthouseService', () => {
let service: LighthouseService; let service: LighthouseService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});
service = TestBed.inject(LighthouseService); service = TestBed.inject(LighthouseService);
}); });