diff options
author | 2020-02-28 17:42:20 +0530 | |
---|---|---|
committer | 2020-02-28 15:35:27 +0000 | |
commit | 4c6f6a443cb2e6effa995e77d56689c1c2dab4ad (patch) | |
tree | 7a961f7c4e2c7de9cea8f2acff473c9f4b11182e /portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts | |
parent | a03dfa273ef6e196bf65acc54b9357d35eb0ed5e (diff) |
Fixed the test cases,added sonar config
Fixed test cases and added sonar config details
Issue-ID: PORTAL-837
Change-Id: Ie4aa104871cfbbd6c6e36500f5ef2e250bafb575
Signed-off-by: jz385p <jegadeesh.babu@att.com>
Diffstat (limited to 'portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts')
-rw-r--r-- | portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts | 199 |
1 files changed, 197 insertions, 2 deletions
diff --git a/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts b/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts index 35f9b50d..02ce3a8a 100644 --- a/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts +++ b/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts @@ -38,25 +38,220 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SchedulerComponent } from './scheduler.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; describe('SchedulerComponent', () => { let component: SchedulerComponent; let fixture: ComponentFixture<SchedulerComponent>; + const payload: any = {"widgetData":"widgetTestData"}; + const policy = ["test1","test2","test3"]; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ SchedulerComponent ] - }) + declarations: [ SchedulerComponent,InformationModalComponent,ConfirmationModalComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule,NgbModule.forRoot()], + providers:[NgbActiveModal] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(SchedulerComponent); component = fixture.componentInstance; + component.payload =payload; + component.policys = policy; + component.schedulerObjConst.WorkflowName = "workFlowName"; + component.schedulerObj.domainData=[{"WorkflowName":"test"}]; + // component.schedulerObj.schedulingInfo.normalDurationInSeconds= 20; + component.vnfObject = { + workflow: null, + vnfNames:'test1' + }; + component.schedulerObj.schedulingInfo = { + normalDurationInSeconds: '', + additionalDurationInSeconds: '', + concurrencyLimit: '', + policyId: '', + vnfDetails: [ + { + groupId: "", + node: [], + changeWindow: [{ + startTime: '', + endTime: '' + }] + }] + }; + + // component.schedulerObj.schedulingInfo.additionalDurationInSeconds= null; + // component.schedulerObj.schedulingInfo.concurrencyLimit=null; + // component.schedulerObj.schedulingInfo['vnfDetails'][0].groupId=null; + // component.schedulerObj.schedulingInfo['vnfDetails'][0].node=null; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('radioSelections should return stubbed value', () => { + spyOn(component, 'radioSelections').and.callThrough(); + component.schedulerForm.checkboxSelection = "true"; + component.radioSelections(); + expect(component.radioSelections).toHaveBeenCalledWith(); + }); + + it('onChangeUpdatePolicyName should return stubbed value', () => { + spyOn(component, 'onChangeUpdatePolicyName').and.callThrough(); + component.onChangeUpdatePolicyName("test1","test1"); + expect(component.onChangeUpdatePolicyName).toHaveBeenCalledWith("test1","test1"); + }); + + it('onChangeUpdateTimeUnit should return stubbed value', () => { + spyOn(component, 'onChangeUpdateTimeUnit').and.callThrough(); + component.onChangeUpdateTimeUnit("HOURS","HOURS"); + expect(component.onChangeUpdateTimeUnit).toHaveBeenCalledWith("HOURS","HOURS"); + }); + it('isDateValid should return stubbed value', () => { + spyOn(component, 'isDateValid').and.callThrough(); + component.isDateValid("10/24/2020"); + expect(component.isDateValid).toHaveBeenCalledWith("10/24/2020"); + }); + it('isStartDateValidFromToday should return stubbed value', () => { + spyOn(component, 'isStartDateValidFromToday').and.callThrough(); + component.isStartDateValidFromToday("10/24/2020"); + expect(component.isStartDateValidFromToday).toHaveBeenCalledWith("10/24/2020"); + component.isStartDateValidFromToday("10/24/2021"); + expect(component.isStartDateValidFromToday).toHaveBeenCalledWith("10/24/2021"); + }); + + it('isToDateGreaterFromDate should return stubbed value', () => { + spyOn(component, 'isToDateGreaterFromDate').and.callThrough(); + component.isToDateGreaterFromDate('10/24/2020','10/24/2021'); + expect(component.isToDateGreaterFromDate).toHaveBeenCalledWith('10/24/2020','10/24/2021'); + component.isToDateGreaterFromDate('10/24/2021','10/24/2020'); + expect(component.isToDateGreaterFromDate).toHaveBeenCalledWith('10/24/2021','10/24/2020'); + }); + + it('submit should return stubbed value', () => { + spyOn(component, 'submit').and.callThrough(); + component.timeSlots = [{"startTime":"10/24/2021"}]; + component.submit(); + expect(component.submit).toHaveBeenCalledWith(); + }); + + it('reject should return stubbed value', () => { + spyOn(component, 'reject').and.callThrough(); + component.timeSlots = [{"startTime":"10/24/2021"}]; + component.reject(); + expect(component.reject).toHaveBeenCalledWith(); + }); + + // it('sendSchedulerReq should return stubbed value', () => { + // spyOn(component, 'sendSchedulerReq').and.callThrough(); + // component.timeSlots = [{"startTime":"10/24/2021"}]; + // component.sendSchedulerReq(); + // expect(component.sendSchedulerReq).toHaveBeenCalledWith(); + // }); + it('seviceCallToGetTimeSlots should return stubbed value', () => { + spyOn(component, 'seviceCallToGetTimeSlots').and.callThrough(); + component.seviceCallToGetTimeSlots(); + expect(component.seviceCallToGetTimeSlots).toHaveBeenCalledWith(); + }); + + it('getPolicy should return stubbed value', () => { + spyOn(component, 'getPolicy').and.callThrough(); + component.getPolicy(); + expect(component.getPolicy).toHaveBeenCalledWith(); + }); + + it('parseErrorMsg should return stubbed value', () => { + const response ={"entity":{"requestError":{"text":"EmptyTest"}}}; + spyOn(component, 'parseErrorMsg').and.callThrough(); + component.parseErrorMsg(response,"TestMethod"); + expect(component.parseErrorMsg).toHaveBeenCalledWith(response,"TestMethod"); + }); + + it('extractChangeManagementCallbackDataStr should return stubbed value', () => { + let response ={"workflow":"Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + spyOn(component, 'extractChangeManagementCallbackDataStr').and.callThrough(); + + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"Replace","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"VNF In Place Software Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"VNF Config Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + + response ={"workflow":"VNF In Place Software Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + }); + it('formValidation should return stubbed value', () => { + spyOn(component, 'formValidation').and.callThrough(); + component.formValidation(); + expect(component.formValidation).toHaveBeenCalledWith(); + }); + + it('convertToSecs should return stubbed value', () => { + spyOn(component, 'convertToSecs').and.callThrough(); + component.convertToSecs(200); + expect(component.convertToSecs).toHaveBeenCalledWith(200); + }); + + it('stopPoll should return stubbed value', () => { + spyOn(component, 'stopPoll').and.callThrough(); + component.stopPoll(); + expect(component.stopPoll).toHaveBeenCalledWith(); + }); + + it('getVnfData should return stubbed value', () => { + spyOn(component, 'getVnfData').and.callThrough(); + component.getVnfData([{"name":"testName"}]); + expect(component.getVnfData).toHaveBeenCalledWith([{"name":"testName"}]); + }); + + it('openConfirmationModal should return stubbed value', () => { + spyOn(component, 'openConfirmationModal').and.callThrough(); + component.openConfirmationModal("Test1","Test1"); + expect(component.openConfirmationModal).toHaveBeenCalledWith("Test1","Test1"); + }); + + it('openInformationModal should return stubbed value', () => { + spyOn(component, 'openInformationModal').and.callThrough(); + component.openInformationModal("Test1","Test1"); + expect(component.openInformationModal).toHaveBeenCalledWith("Test1","Test1"); + }); + + + + + + + + + + }); |