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 { PatientInfo } from '../../ewv-viewer/ewv-viewer.model';
import { PatientInfoComponent } from './patient-info.component';
import { EwvViewerService } from '../../ewv-viewer/ewv-viewer.service';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';

describe('PatientInfoComponent', () => {
let component: PatientInfoComponent;
let ewvViewerService: EwvViewerService;

beforeEach(() => {
ewvViewerService = new EwvViewerService(null, null);
component = new PatientInfoComponent(ewvViewerService);
});

it('should be created', () => {
expect(component).toBeTruthy();
});


it('test ngOnChanges method', () => {
spyOn(component, 'populateData');

component.data = {
patientName: 'PATIENT_NAME',
patientIdNumber: null,
dateOfBirth: undefined,
dateOfDeath_5010: '',
gender: 'GENDER',
addressLineOne: 'ADDRESS_LINE_ONE',
addressLineTwo: null,
city: 'CITY',
state: 'STATE',
postalCode: '90210',
country: '',
firstName: 'FIRST_NAME',
lastName: 'LAST_NAME'
};

component.ngOnChanges();

expect(component.data.patientName).toEqual('PATIENT_NAME');
expect(component.data.patientIdNumber).toEqual('\u2013\u2013\u2013');
expect(component.data.dateOfBirth).toEqual('\u2013\u2013\u2013');
expect(component.data.dateOfDeath_5010).toEqual('\u2013\u2013\u2013');
expect(component.data.gender).toEqual('GENDER');
expect(component.data.addressLineOne).toEqual('ADDRESS_LINE_ONE');
expect(component.data.addressLineTwo).toEqual('\u2013\u2013\u2013');
expect(component.data.city).toEqual('CITY');
expect(component.data.state).toEqual('STATE');
expect(component.data.postalCode).toEqual('90210');
expect(component.data.country).toEqual('\u2013\u2013\u2013');
expect(component.data.firstName).toEqual('FIRST_NAME');
expect(component.data.lastName).toEqual('LAST_NAME');

expect(component.populateData).toHaveBeenCalled();
});

it('test ngAfterViewInit method"', () => {
expect(component.data).toEqual(undefined);
ewvViewerService.subject = new BehaviorSubject<boolean>(false);
expect(component.collapseState).toEqual(true);
expect(component.accordionId).toEqual(undefined);

component.ngAfterViewInit();

expect(component.collapseState).toEqual(false);
expect(component.data).toEqual(undefined);
expect(component.accordionId).toEqual(undefined);
});

it('test getCopyAddressTextValue method', () => {
component.data = {
firstName: 'John',
lastName: 'Smith',
addressLineOne: '123 Elm Street',
addressLineTwo: 'Apartment 789',
city: 'Beverly Hills',
state: 'California',
postalCode: '90210',
country: 'USA',
patientName: '',
patientIdNumber: '',
dateOfBirth: '',
dateOfDeath_5010: '',
gender: 'Male'
};

const returnValue = component.getCopyAddressTextValue();
expect(returnValue).toEqual(
'John Smith\r123 Elm Street\rApartment 789\rBeverly Hills, California 90210\rUSA'
);
});

it('test ngOnDestroy method', () => {
spyOn(component.collapseStateSubscription, 'unsubscribe');
spyOn(component.isSplitSubscription, 'unsubscribe');

component.ngOnDestroy();

expect(component.collapseStateSubscription.unsubscribe).toHaveBeenCalled();
expect(component.isSplitSubscription.unsubscribe).toHaveBeenCalled();
});

it('test getFirstName method', () => {
component.data = new PatientInfo();
component.data.firstName = 'FirstName';
const returnValue = component.getFirstName();
expect(returnValue).toEqual('FirstName');
});

it('test getLastName method', () => {
component.data = new PatientInfo();
component.data.lastName = 'LastName';
const returnValue = component.getLastName();
expect(returnValue).toEqual('LastName');
});

it('test getAddressOne method', () => {
component.data = new PatientInfo();
component.data.addressLineOne = 'AddressLineOne';
const returnValue = component.getAddressOne();
expect(returnValue).toEqual('AddressLineOne');
});

it('test getAddressTwo method: "component.data.patientInfo" property has no "addressLineTwo" property', () => {
component.data = new PatientInfo();
component.data.addressLineTwo = '';
const returnValue = component.getAddressTwo();
expect(returnValue).toEqual('');
});

it('test getAddressTwo method: "component.data.patientInfo" property has "addressLineTwo" property', () => {
component.data = new PatientInfo();
component.data.addressLineTwo = 'AddressLineTwo';
const returnValue = component.getAddressTwo();
expect(returnValue).toEqual('AddressLineTwo');
});

it('test getCity method: "component.data.patientInfo" property has no "city" property', () => {
component.data = new PatientInfo();
component.data.city = '';
const returnValue = component.getCity();
expect(returnValue).toEqual('');
});

it('test getCity method: "component.data.patientInfo" property has "city" property', () => {
component.data = new PatientInfo();
component.data.city = 'City';
const returnValue = component.getCity();
expect(returnValue).toEqual('City');
});

it('test getState method', () => {
component.data = new PatientInfo();
component.data.state = 'State';
const returnValue = component.getState();
expect(returnValue).toEqual('State');
});

it('test getZipCode method', () => {
component.data = new PatientInfo();
component.data.postalCode = 'ZipCode';
const returnValue = component.getZipCode();
expect(returnValue).toEqual('ZipCode');
});

it('test getCountry method', () => {
component.data = new PatientInfo();
component.data.country = 'Country';
const returnValue = component.getCountry();
expect(returnValue).toEqual('Country');
});

it('test copyPatientInformationAddressToClipboard method', () => {
spyOn(component, 'getCopyAddressTextValue').and.callFake(
() => 'CopyAddressTextValue'
);

const returnedElement = {
value: '',
setAttribute: () => true,
select: () => true,
style: {
position: '',
left: ''
}
};
spyOn(document, 'createElement').and.callFake(() => returnedElement);

spyOn(document, 'execCommand');
spyOn(document.body, 'appendChild');
spyOn(document.body, 'removeChild');
spyOn(returnedElement, 'setAttribute');
spyOn(returnedElement, 'select');

component.copyPatientInformationAddressToClipboard();

expect(document.createElement).toHaveBeenCalled();
expect(document.createElement).toHaveBeenCalledWith('textarea');

expect(document.body.appendChild).toHaveBeenCalled();
expect(document.body.appendChild).toHaveBeenCalledWith(returnedElement);

expect(document.body.removeChild).toHaveBeenCalled();
expect(document.body.removeChild).toHaveBeenCalledWith(returnedElement);

expect(document.execCommand).toHaveBeenCalled();
expect(document.execCommand).toHaveBeenCalledWith('copy');

expect(returnedElement.setAttribute).toHaveBeenCalled();
expect(returnedElement.setAttribute).toHaveBeenCalledWith('readonly', '');

expect(returnedElement.select).toHaveBeenCalled();

expect(returnedElement.style.position).toEqual('absolute');
expect(returnedElement.style.left).toEqual('-9999px');
expect(returnedElement.value).toEqual('CopyAddressTextValue');

expect(component.getCopyAddressTextValue).toHaveBeenCalled();
});

it('test populateData method', () => {
ewvViewerService.isSplitView = new BehaviorSubject<boolean>(false);
expect(component.isSplitView).toEqual(undefined);

component.populateData();

expect(component.isSplitView).toEqual(false);
});

});