Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { FormBuilder } from '@angular/forms';
import { Observable } from 'rxjs/Observable';
import { Search275Service } from './search275.service';
import { Search275Component } from './search275.component';
import { ResponseModel, Search275Model } from './search275.component.model';
import { AttachmentViewerService } from '../../shared/attachment-viewer/attachment-viewer.service';
import { AuthenticationService } from '../../auth/auth.service';
import { AppSettingsService } from './../../shared/app-settings/app-settings.service';
describe('Search275Component', () => {
let appSettingsService: AppSettingsService;
let component: Search275Component;
let searchService: Search275Service;
let fb: FormBuilder;
let attachmentService: AttachmentViewerService;
let authenticationService: AuthenticationService;
beforeEach(() => {
authenticationService = new AuthenticationService(null, null, null, null);
appSettingsService = new AppSettingsService(authenticationService, null);
fb = new FormBuilder();
searchService = new Search275Service(null);
attachmentService = new AttachmentViewerService(null);
component = new Search275Component(
fb,
searchService,
attachmentService,
authenticationService,
appSettingsService,
null
);
});
it('should be created', () => {
expect(component).toBeTruthy();
});
it('should test ngOnInit', () => {
const formInitSpy = spyOn(component, 'formInit');
const TableInitSpy = spyOn(component, 'tableInit');
const getUserDataSpy = spyOn(component, 'getUserData');
const appSettingsServiceSpy = spyOn(
appSettingsService,
'getMenu'
).and.callFake(() => new Observable(observer => observer.next('')));
component.ngOnInit();
expect(appSettingsServiceSpy).toHaveBeenCalled();
expect(formInitSpy).toHaveBeenCalled();
expect(TableInitSpy).toHaveBeenCalled();
});
it('should test formInit', () => {
component.formInit();
const attachIdLx = component.form.get('attachIdLx');
const claimId = component.form.get('claimId');
const patientIdentifier = component.form.get('patientIdentifier');
const providerNpi = component.form.get('providerNpi');
attachIdLx.setValue('9.123');
claimId.setValue('9123');
patientIdentifier.setValue('9123');
providerNpi.setValue('9123');
expect(attachIdLx.valid).toBeTruthy();
expect(claimId.valid).toBeTruthy();
expect(patientIdentifier.valid).toBeTruthy();
expect(providerNpi.valid).toBeTruthy();
});
it('should test tableInit method', () => {
component.tableInit();
expect(component.tableSettings.extShow).toEqual(true);
expect(component.tableSettings.imgColumn).toEqual(false);
});
it('should test resetForm method', () => {
component.formInit();
component.requestModel.claimId = '10000';
component.errorStatus = true;
component.errorMsg = 'error';
component.resetForm();
expect(component.requestModel.claimId).toBeFalsy();
expect(component.errorStatus).toBeFalsy();
expect(component.errorMsg).toBeFalsy();
});
it('should test search method', () => {
component.paginationSettings.currentPage = 10;
const fetchDataSpy = spyOn(component, 'fetchData');
component.search();
expect(component.paginationSettings.currentPage).toBe(1);
expect(fetchDataSpy).toHaveBeenCalled();
});
it('should test fetchData method', () => {
component.formInit();
component.form.get('claimServiceStartDate').setValue('10/20/2017');
component.form.get('claimServiceEndDate').setValue('01/01/2018');
const data: ResponseModel = new ResponseModel();
data.response = [new Search275Model()];
data.pageSize = 10;
data.sortColumn = 'attachmentId';
data.pageNumber = 1;
data.serviceDate = 10;
data.attachType = 'jpg';
data.totalNumberOfResults = 30;
const serviceSpy = spyOn(searchService, 'search').and.callFake(() => {
return new Observable(observer => {
observer.next(data.response);
});
});
component.fetchData();
expect(serviceSpy).toHaveBeenCalled();
});
it('should test updateTable method', () => {
const fetchDataSpy = spyOn(component, 'fetchData');
component.updateTable();
expect(fetchDataSpy).toHaveBeenCalled();
});
it('should test onDisplayAttachmentViewer method', () => {
const attachmentServiceSpy = spyOn(attachmentService, 'setAttachmentViewerState');
component.showResults = true;
component.onDisplayAttachmentViewer({attachId: '1', attachIdLx: '2', status: 'Active', pathAddress: ['true']});
expect(component.showResults).toEqual(false);
expect(component.fileList).toEqual(['true']);
});
});