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 { ServiceLvlAmbulanceInfoComponent } from './service-lvl-ambulance-info.component';
import { EwvViewerService } from '../../ewv-viewer/ewv-viewer.service';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
describe('ServiceLvlAmbulanceInfoComponent', () => {
let component: ServiceLvlAmbulanceInfoComponent;
let ewvViewerService: EwvViewerService;
beforeEach(() => {
ewvViewerService = new EwvViewerService(null, null);
component = new ServiceLvlAmbulanceInfoComponent(ewvViewerService);
});
it('should be created', () => {
expect(component).toBeTruthy();
});
it('test ngOnInit method: verify "component.collapseState" has correct value for default "ewvViewerService.collapseState"', () => {
expect(component.collapseState).toEqual(true);
spyOn(component, 'populateData');
component.ngOnInit();
expect(component.collapseState).toEqual(true);
expect(component.populateData).toHaveBeenCalled();
});
it('test ngOnInit method: verify "component.collapseState" has correct value for TRUE "ewvViewerService.collapseState"', () => {
ewvViewerService.subject = new BehaviorSubject<boolean>(true);
expect(component.collapseState).toEqual(true);
spyOn(component, 'populateData');
component.ngOnInit();
expect(component.collapseState).toEqual(true);
expect(component.populateData).toHaveBeenCalled();
});
it('test ngOnInit method: verify "component.collapseState" has correct value for FALSE "ewvViewerService.collapseState"', () => {
ewvViewerService.subject = new BehaviorSubject<boolean>(false);
expect(component.collapseState).toEqual(true);
spyOn(component, 'populateData');
component.ngOnInit();
expect(component.collapseState).toEqual(false);
expect(component.populateData).toHaveBeenCalled();
});
it('test populateData method', () => {
const serviceLinesInfoData = [
{ serviceLineLevelAmbulanceInfo: 'SERVICE_LINE_LEVEL_AMBULANCE_INFO_1' },
{ serviceLineLevelAmbulanceInfo: 'SERVICE_LINE_LEVEL_AMBULANCE_INFO_2' }
];
component.data = {
serviceLinesInfo: serviceLinesInfoData
};
expect(component.serviceLevel).toEqual([]);
expect(component.serviceLevelAmbulance).toEqual([]);
component.populateData();
expect(component.serviceLevel).toEqual(serviceLinesInfoData);
expect(component.serviceLevelAmbulance.length).toEqual(2);
expect(component.serviceLevelAmbulance[0]).toEqual(
'SERVICE_LINE_LEVEL_AMBULANCE_INFO_1'
);
expect(component.serviceLevelAmbulance[1]).toEqual(
'SERVICE_LINE_LEVEL_AMBULANCE_INFO_2'
);
});
it('test ngOnChanges method', () => {
spyOn(component, 'populateData');
expect(component.data).toEqual(undefined);
let changes;
changes = {
data: {
currentValue: 'CURRENT_VALUE'
}
};
component.ngOnChanges(changes);
expect(component.data).toEqual('CURRENT_VALUE');
expect(component.populateData).toHaveBeenCalled();
});
it('test ngOnDestroy method', () => {
component.ngOnInit();
spyOn(component.collapseStateSubscription, 'unsubscribe');
component.ngOnDestroy();
expect(component.collapseStateSubscription.unsubscribe).toHaveBeenCalled();
});
});