WIP fixing tests (1 failure)

This commit is contained in:
Jason Kulatunga 2023-10-30 11:02:41 -07:00
parent 627b697741
commit 8652218180
No known key found for this signature in database
7 changed files with 60 additions and 6 deletions

View File

@ -24,6 +24,7 @@ export class MedicalSourcesCardComponent implements OnInit {
}
getSourceDisplayName(sourceItem: SourceListItem): string {
if(!sourceItem) return "Unknown"
if(sourceItem.metadata?.display) {
return sourceItem.metadata?.display
}

View File

@ -1,6 +1,11 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BackgroundJobsComponent } from './background-jobs.component';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HTTP_CLIENT_TOKEN} from '../../dependency-injection';
import {HttpClient} from '@angular/common/http';
describe('BackgroundJobsComponent', () => {
let component: BackgroundJobsComponent;
@ -8,7 +13,14 @@ describe('BackgroundJobsComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ BackgroundJobsComponent ]
declarations: [ BackgroundJobsComponent ],
imports: [HttpClientTestingModule],
providers: [
{
provide: HTTP_CLIENT_TOKEN,
useClass: HttpClient,
},
]
})
.compileComponents();

View File

@ -4,6 +4,7 @@ import { ReportLabsComponent } from './report-labs.component';
import {FastenApiService} from '../../services/fasten-api.service';
import {NgbModalModule} from '@ng-bootstrap/ng-bootstrap';
import {of} from 'rxjs';
import {RouterTestingModule} from '@angular/router/testing';
describe('ReportLabsComponent', () => {
let component: ReportLabsComponent;
@ -12,9 +13,10 @@ describe('ReportLabsComponent', () => {
beforeEach(async () => {
mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources'])
mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'queryResources'])
await TestBed.configureTestingModule({
declarations: [ ReportLabsComponent ],
imports: [RouterTestingModule],
providers: [{
provide: FastenApiService,
useValue: mockedFastenApiService
@ -22,6 +24,7 @@ describe('ReportLabsComponent', () => {
})
.compileComponents();
mockedFastenApiService.getResources.and.returnValue(of([]));
mockedFastenApiService.queryResources.and.returnValue(of([]));
fixture = TestBed.createComponent(ReportLabsComponent);
component = fixture.componentInstance;

View File

@ -1,12 +1,23 @@
import { TestBed } from '@angular/core/testing';
import { EventBusService } from './event-bus.service';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {HTTP_CLIENT_TOKEN} from '../dependency-injection';
import {HttpClient} from '@angular/common/http';
describe('EventBusService', () => {
let service: EventBusService;
beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
{
provide: HTTP_CLIENT_TOKEN,
useClass: HttpClient,
},
]
});
service = TestBed.inject(EventBusService);
});

View File

@ -1,6 +1,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ImageListGroupWidgetComponent } from './image-list-group-widget.component';
import {FastenApiService} from '../../services/fasten-api.service';
import {HTTP_CLIENT_TOKEN} from '../../dependency-injection';
import {HttpClient} from '@angular/common/http';
import {HttpClientTestingModule} from '@angular/common/http/testing';
describe('ImageListGroupWidgetComponent', () => {
let component: ImageListGroupWidgetComponent;
@ -8,7 +12,13 @@ describe('ImageListGroupWidgetComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ImageListGroupWidgetComponent ]
imports: [ ImageListGroupWidgetComponent, HttpClientTestingModule ],
providers: [
{
provide: HTTP_CLIENT_TOKEN,
useClass: HttpClient,
},
]
})
.compileComponents();

View File

@ -16,7 +16,6 @@ describe('PatientVitalsWidgetComponent', () => {
beforeEach(async () => {
mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['queryResources'])
await TestBed.configureTestingModule({
imports: [ PatientVitalsWidgetComponent, RouterTestingModule ],
providers: [

View File

@ -1,16 +1,34 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RecordsSummaryWidgetComponent } from './records-summary-widget.component';
import {FastenApiService} from '../../services/fasten-api.service';
import {HTTP_CLIENT_TOKEN} from '../../dependency-injection';
import {HttpClient} from '@angular/common/http';
import {RouterTestingModule} from '@angular/router/testing';
import {of} from 'rxjs';
describe('RecordsSummaryWidgetComponent', () => {
let component: RecordsSummaryWidgetComponent;
let fixture: ComponentFixture<RecordsSummaryWidgetComponent>;
let mockedFastenApiService
beforeEach(async () => {
mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getSummary'])
await TestBed.configureTestingModule({
declarations: [ RecordsSummaryWidgetComponent ]
imports: [ RecordsSummaryWidgetComponent, RouterTestingModule ],
providers: [
{
provide: FastenApiService,
useValue: mockedFastenApiService
},
{
provide: HTTP_CLIENT_TOKEN,
useClass: HttpClient,
}
]
})
.compileComponents();
mockedFastenApiService.getSummary.and.returnValue(of({}));
fixture = TestBed.createComponent(RecordsSummaryWidgetComponent);
component = fixture.componentInstance;