2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 Modification Copyright (C) 2018 IBM.
7 ===================================================================
9 Unless otherwise specified, all software contained herein is licensed
10 under the Apache License, Version 2.0 (the License);
11 you may not use this software except in compliance with the License.
12 You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
22 ============LICENSE_END============================================
24 /* tslint:disable:no-unused-variable */
25 import { ComponentFixture, TestBed, async, inject } from '@angular/core/testing';
26 import { Http, Response, ResponseOptions, XHRBackend } from '@angular/http';
28 import { BuildDesignComponent } from '../build-artifacts.component';
29 import { DialogService } from 'ng2-bootstrap-modal';
30 import { FormsModule } from '@angular/forms';
31 import { HttpModule } from '@angular/http';
32 import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
33 import { MappingEditorService } from '../../..//shared/services/mapping-editor.service';
34 import { NO_ERRORS_SCHEMA } from '@angular/core';
35 import { NgModule } from '@angular/core';
36 import { NgProgress } from 'ngx-progressbar';
37 import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
38 import { NotificationService } from '../../../shared/services/notification.service';
39 import { Observable } from 'rxjs/Observable';
40 import { ParamShareService } from '../../..//shared/services/paramShare.service';
41 import { ReferenceDataformComponent } from './reference-dataform.component';
42 import { RouterTestingModule } from '@angular/router/testing';
43 import { SharedModule } from '../../../shared/shared.module';
44 import { environment } from '../../../../environments/environment';
46 describe('ReferenceDataformComponent', () => {
47 let component: ReferenceDataformComponent;
48 let fixture: ComponentFixture<ReferenceDataformComponent>;
49 let service: MockMappingService;
51 let httpMock: HttpUtilService
52 //mockingthe data for mappingEditorService
61 "output": { "data": { "block": "{\"userID\":null,\"designInfo\":null,\"statusInfo\":null,\"artifactInfo\":[{\"artifact-content\":\" {\\\"reference_data\\\":[{\\\"action\\\":\\\"Configure\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"template\\\":\\\"Y\\\",\\\"vm\\\":[],\\\"device-protocol\\\":\\\"ANSIBLE\\\",\\\"user-name\\\":\\\"root\\\",\\\"port-number\\\":\\\"830\\\",\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"template_Configure_Btesting123_0.0.1V.json\\\",\\\"artifact-type\\\":\\\"config_template\\\"},{\\\"artifact-name\\\":\\\"pd_Configure_Btesting123_0.0.1V.yaml\\\",\\\"artifact-type\\\":\\\"parameter_definitions\\\"}],\\\"scopeType\\\":\\\"vnf-type\\\"},{\\\"action\\\":\\\"AllAction\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"reference_AllAction_Btesting123_0.0.1V.json\\\",\\\"artifact-type\\\":\\\"reference_template\\\"}]},{\\\"action\\\":\\\"ConfigScaleOut\\\",\\\"action-level\\\":\\\"vnf\\\",\\\"scope\\\":{\\\"vnf-type\\\":\\\"Btesting123\\\",\\\"vnfc-type\\\":\\\"\\\"},\\\"template\\\":\\\"Y\\\",\\\"vm\\\":[{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":1,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]},{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":2,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]},{\\\"template-id\\\":\\\"id1\\\",\\\"vm-instance\\\":3,\\\"vnfc\\\":[{\\\"vnfc-instance\\\":\\\"1\\\",\\\"vnfc-function-code\\\":\\\"12313\\\",\\\"ipaddress-v4-oam-vip\\\":\\\"Y\\\",\\\"group-notation-type\\\":\\\"first-vnfc-name\\\",\\\"group-notation-value\\\":\\\"pair\\\",\\\"vnfc-type\\\":\\\"vDBE-V\\\"}]}],\\\"device-protocol\\\":\\\"CHEF\\\",\\\"user-name\\\":\\\"root\\\",\\\"port-number\\\":\\\"830\\\",\\\"artifact-list\\\":[{\\\"artifact-name\\\":\\\"template_ConfigScaleOut_Btesting123_0.0.1V_id1.json\\\",\\\"artifact-type\\\":\\\"config_template\\\"},{\\\"artifact-name\\\":\\\"pd_ConfigScaleOut_Btesting123_0.0.1V_id1.yaml\\\",\\\"artifact-type\\\":\\\"parameter_definitions\\\"}],\\\"scopeType\\\":\\\"vnf-type\\\",\\\"template-id-list\\\":[\\\"id1\\\"]}]}\"}]}", "requestId": "563507520187" }, "status": { "code": "400", "message": "success" } },
63 "status": { code: "400", message: "success" }
70 class MockMappingService {
71 public latestAction; // = {"action":"Configure"}
80 downloadDataObject = {
93 referenceNameObjects = [
97 action: "StartApplication"
101 setTemplateMappingDataFromStore(data) {
110 setParamContent(data) {
113 setSessionParamData(data) {
117 saveLatestAction() { }
118 saveLatestIdentifier() { }
119 changeNavDownloadData() { }
120 changeNavAppData() { }
122 class MockreferenceDataObject { }
123 beforeEach(async(() => {
124 TestBed.configureTestingModule({
125 declarations: [ReferenceDataformComponent],
126 schemas: [NO_ERRORS_SCHEMA],
129 FormsModule, RouterTestingModule, HttpModule, NgbModule.forRoot(),
130 SharedModule.forRoot()
133 BuildDesignComponent, {
134 provide: MappingEditorService,
135 useClass: MockMappingService
139 NotificationService, {
140 provide: HttpUtilService,
145 }).compileComponents();
149 fixture = TestBed.createComponent(ReferenceDataformComponent);
150 component = fixture.componentInstance;
151 // component = new ReferenceDataformComponent(service)
152 fixture.detectChanges();
153 service = TestBed.get(MappingEditorService)
154 httpMock = TestBed.get(HttpUtilService)
155 sessionStorage.setItem('vnfParams', JSON.stringify({ vnfType: "test", vnfcType: "testVnfcType" }));
156 // component = new ReferenceDataformComponent(service)
158 it('should create reference component', () => {
159 expect(component).toBeTruthy();
161 it('Should load data from mapping sevice', () => {
163 expect(component.tempAllData.length).toBe(2)
165 it('testing init method', () => {
167 expect(component.tempAllData.length).toBe(2)
170 it("should set app data from service", () => {
172 expect(component.appData)
176 it("should set download from service", () => {
178 expect(component.downloadData)
182 it('Should reset form', () => {
183 component.resetForm()
184 expect(component.referenceDataObject['device-protocol']).toBe('')
185 expect(component.referenceDataObject['action-level']).toBe('vnf')
186 expect(component.referenceDataObject.template).toBe('Y')
187 expect(component.referenceDataObject['user-name']).toBe('')
188 expect(component.Sample['vnfc-type']).toBe('')
189 expect(component.refernceScopeObj.sourceType).toBe('')
190 expect(component.referenceDataObject['port-number']).toBe('')
192 it("prepare reference method at vnf level", () => {
194 component.referenceDataObject = {
196 'action-level': 'vnf',
203 'device-protocol': '',
208 component.vnfcIdentifier = '346';
209 component.prepareReferenceObject();
210 expect(component.referenceDataObject['action-level']).toBe("vnf")
213 it("prepare reference method at vnfc level", () => {
215 component.referenceDataObject = {
217 'action-level': 'vnf',
220 'vnfc-type-list': ['346']
224 'device-protocol': '',
229 component.vnfcIdentifier = '346';
230 component.prepareReferenceObject();
231 expect(component.referenceDataObject['action-level']).toBe("vnfc")
234 it("prepare reference method at vnf and vnfc level", () => {
236 component.referenceDataObject = {
237 action: 'starttApplication',
238 'action-level': 'vnf',
241 'vnfc-type-list': ['346']
245 'device-protocol': 'ANSIBLE',
250 component.vnfcIdentifier = '346';
251 component.prepareReferenceObject();
253 expect(component.referenceDataObject['action-level']).toBe("vnf")
255 //deviceprotocols netconf
256 it("prepare reference method testing with netconf", () => {
258 component.referenceDataObject = {
259 action: 'starttApplication',
260 'action-level': 'vnf',
263 'vnfc-type-list': ['346']
267 'device-protocol': 'NETCONF-XML',
273 component.prepareReferenceObject();
274 expect(component.referenceDataObject['action-level']).toBe("vnf")
277 it("prepare reference method at template id list", () => {
279 component.referenceDataObject = {
280 action: 'ConfigScaleOut',
281 'action-level': 'vnf',
284 'vnfc-type-list': ['346']
288 'device-protocol': 'NETCONF-XML',
295 component.referenceDataObject['template-id-list'] = ['id1', 'id2']
297 component.prepareReferenceObject();
299 expect(component.referenceDataObject['action-level']).toBe("vnf")
301 it("prepare reference method at vnfc level", () => {
303 component.referenceDataObject = {
304 action: 'startApplication',
305 'action-level': 'vnfc',
308 'vnfc-type-list': ['346']
312 'device-protocol': '',
317 component.prepareReferenceObject();
318 expect(component.referenceDataObject['action-level']).toBe("vnf")
320 it("prepare reference method at vnf level", () => {
322 component.referenceDataObject = {
323 action: 'ConfigScaleOut',
324 'action-level': 'vnf',
327 'vnfc-type-list': ['346']
331 'device-protocol': '',
336 component.vnfcIdentifier = '346';
337 component.prepareReferenceObject();
338 expect(component.referenceDataObject['action-level']).toBe("vnf")
341 it('should create reference component', () => {
343 expect(component).toBeTruthy();
345 it('configscaleout test', () => {
346 service.latestAction = {
347 action: 'ConfigScaleOut',
348 'action-level': 'vnf',
355 'device-protocol': '',
360 service.referenceNameObjects = [
364 action: "StartApplication"
368 expect(component.referenceDataObject.action).toBe("ConfigScaleOut");
372 it('shoud add vms with template id when the acti0on is configscaleout ', () => {
373 component.referenceDataObject = {
374 action: 'ConfigScaleOut',
375 'action-level': 'vnf',
378 'vnfc-type-list': ['346']
391 'device-protocol': '',
397 component.refernceScopeObj.from = "3"
400 expect(component.referenceDataObject.vm.length).toBe(4);
402 it('shoud add vms with template id when the action is not configscaleout', () => {
403 component.referenceDataObject = {
405 'action-level': 'vnf',
408 'vnfc-type-list': ['346']
421 'device-protocol': '',
427 component.refernceScopeObj.from = "3"
430 expect(component.referenceDataObject.vm[0]['template-id']).toBe(undefined);
433 it('testing ngdestroy', () => {
434 this.uploadFileName = 'testing'
435 component.ngOnDestroy()
436 expect(component.uploadedDataArray.length).toBe(0);
437 expect(component.uploadFileName).toBe('');
439 it('should validate numbers', () => {
441 component.numberValidation(1)
442 expect(component.numberOfVmTest).toBe(true);
446 it('should validate numbers if input is string', () => {
448 component.numberValidation('test')
449 expect(component.numberOfVmTest).toBe(false);
453 it('testing check if elements exixts in an array', () => {
455 let x = component.checkIfelementExistsInArray(2, [1, 2, 3])
456 expect(x).toBeTruthy();
459 it('should set action in session if type is action', () => {
461 component.updateSessionValues("test event for action", "action")
463 expect(sessionStorage.getItem('action')).toBe('test event for action');
465 it('should set action in session if type is vnfType', () => {
467 component.updateSessionValues("test event for vnfType", "vnfType")
469 expect(sessionStorage.getItem('vnfType')).toBe('test event for vnfType');
472 it('should add vnfs on to reference Object ', () => {
474 component.referenceDataObject = {
476 'action-level': 'vnf',
479 'vnfc-type-list': ['346']
492 'device-protocol': '',
498 component.addVnfcData(0)
500 expect(component.referenceDataObject.vm[0].vnfc.length).toBe(2);
503 it("should remove feature from the reference object ", () => {
504 component.referenceDataObject = {
506 'action-level': 'vnf',
509 'vnfc-type-list': ['346']
529 'device-protocol': '',
535 component.removeFeature(0, 0, 0)
537 expect(component.referenceDataObject.vm.length).toBe(1)
540 it("remove templateIds vm if action is confiogscaleout", () => {
541 component.referenceDataObject = {
542 action: 'ConfigScaleOut',
543 'action-level': 'vnf',
546 'vnfc-type-list': ['346']
551 "template-id": "klmklj",
555 "vnfc-instance": "1",
556 "vnfc-function-code": "klkl",
557 "ipaddress-v4-oam-vip": "",
558 "group-notation-type": "",
559 "group-notation-value": "",
564 "template-id": "test 12",
568 "vnfc-instance": "1",
569 "vnfc-function-code": "klkl",
570 "ipaddress-v4-oam-vip": "",
571 "group-notation-type": "",
572 "group-notation-value": "",
578 'device-protocol': '',
584 component.removeFeature(0, 0, 'test 12')
586 //expect(component.referenceDataObject.vm.length).toBe(2)
590 it("should add capabilities", () => {
591 component.uploadedDataArray = [
594 component.addVmCapabilitiesData()
596 expect(component.tempAllData.length).toBe(3)
598 it("should add capabilities", () => {
599 service.latestAction = {
600 action: 'OpenStack Actions',
601 'action-level': 'vnf',
608 'device-protocol': '',
613 service.referenceNameObjects = [
617 action: "StartApplication"
621 component.prepareReferenceObject();
623 expect(component.referenceDataObject['action-level']).toBe("vnf")
626 it("should add capabilities", () => {
627 service.latestAction = {
628 action: 'OpenStack Actions',
629 'action-level': 'vnf',
636 'device-protocol': '',
642 component.referenceDataObject.action = "OpenStack Actions"
643 service.referenceNameObjects = [
647 action: "StartApplication"
651 component.prepareReferenceObject();
653 expect(component.referenceDataObject['action-level']).toBe("vnf")
656 it("should switch vms if action is configscaleout", () => {
658 component.currentAction = "ConfigScaleOut"
659 service.latestAction = {
660 action: 'OpenStack Actions',
661 'action-level': 'vnf',
668 'device-protocol': '',
673 service.referenceNameObjects = [
677 action: "StartApplication"
681 component.tempAllData = [
683 action: "ConfigScaleOut",
688 component.prepareReferenceObject();
690 expect(component.referenceDataObject.vm.length).toBe(2)
692 it("should switch vms if action is configscaleout", () => {
694 component.currentAction = "ConfigScaleOut"
695 service.latestAction = {
696 action: 'OpenStack Actions',
697 'action-level': 'vnf',
704 'device-protocol': '',
709 service.referenceNameObjects = [
713 action: "StartApplication"
717 component.tempAllData = [
719 action: "startAplicaton"
723 component.prepareReferenceObject();
725 expect(component.referenceDataObject.vm.length).toBe(0)
727 it('shoud show template identifier when action is config scaleout', () => {
728 let data = 'ConfigScaleOut'
729 component.toggleIdentifier(data)
730 expect(component.isConfigScaleOut).toBe(true);
732 it('shoud show template identifier when action is config scaleout', () => {
733 let data = 'startApplication'
734 component.toggleIdentifier(data)
735 expect(component.isConfigScaleOut).toBe(false);
738 it('Should call get artifact', () => {
740 service.referenceNameObjects = undefined
742 expect(component.tempAllData.length).toBe(2)
745 it('Should call get artifact', () => {
746 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
747 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
748 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
750 component.getArtifact()
752 expect(spy).toHaveBeenCalled();
753 expect(component.tempAllData.length).toBe(3);
756 it('Save file - should not process if action is null ', () => {
757 component.referenceDataObject.action = ""
758 let fileSaved = component.save({}, true)
759 expect(fileSaved).toBe(undefined)
761 it('Save file - should not process if device protocol is null ', () => {
762 component.referenceDataObject.action = "Configure"
763 component.referenceDataObject['device-protocol'] = ''
764 let fileSaved = component.save({}, true)
765 expect(fileSaved).toBe(undefined)
767 it('Save file - should not process if device protocol is null ', () => {
768 component.referenceDataObject.action = "Configure"
769 component.referenceDataObject['device-protocol'] = "test"
770 component.downloadData.template.templateData = { "test": "test" }
771 component.downloadData.template.nameValueData = { "test": "test" }
772 component.downloadData.pd.pdData = "test"
773 let fileSaved = component.save({}, true)
774 //expect(fileSaved).toBe(undefined)
777 it('Save to appc file - should not process if action is null ', () => {
778 component.referenceDataObject.action = ""
779 let fileSaved = component.saveToAppc();
780 expect(fileSaved).toBe(undefined)
782 it('Save to app cfile - should not process if device protocol is null ', () => {
783 component.referenceDataObject['device-protocol'] = ""
784 component.referenceDataObject.action = "Configure"
785 let fileSaved = component.saveToAppc();
786 expect(fileSaved).toBe(undefined)
788 it('Save to appc file - should not process if device protocol is null ', () => {
789 component.tempAllData = [
793 'vnf-type': "testVnf"
797 component.referenceDataObject.action = "Configure"
798 component.referenceDataObject['device-protocol'] = "test"
799 component.appData.template.templateData = { "test": "test" }
800 component.appData.template.nameValueData = { "test": "test" }
801 component.appData.pd = { "test": "test" }
802 component.actionChanged = true
803 component.currentAction = "COnfigure"
804 let fileSaved = component.saveToAppc();
805 expect(fileSaved).toBe(undefined)
808 // it('uploadfile ', () => { let files = { 0: {name:'foo.XLS', size:
809 // 500001} }; var mockEVet = { target:{files:files} }
810 // component.upload(mockEVet) //expect(fileSaved).toBe(undefined) })
812 it('downloadTemplate() of reference dataform', () => {
813 component.downloadTemplate()
816 it('downloadNameValue() of reference dataform', () => {
817 component.downloadNameValue()
820 it('downloadPd() of reference dataform', () => {
821 component.downloadPd()
823 it('validateTempAllData() of reference dataform', () => {
824 component.validateTempAllData()
826 it('retriveFromAppc() of reference dataform', () => {
827 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
828 component.retriveFromAppc()
829 expect(component.noCacheData).toBeFalsy()
831 it('retriveFromAppc() of reference dataform for false', () => {
832 sessionStorage.setItem('updateParams', 'undefined')
833 component.retriveFromAppc()
834 expect(component.noCacheData).toBeTruthy()
836 it(' cloneMessage(servermessage) of reference dataform', () => {
837 let servermessage = {
840 component.cloneMessage(servermessage)
843 it('resetGroupNotation() of reference dataform for false case', () => {
844 component.resetGroupNotation()
845 expect(component.disableGrpNotationValue).toBeFalsy()
847 it('resetGroupNotation() of reference dataform for true case', () => {
848 component.Sample['group-notation-type'] = "existing-group-name"
849 component.resetGroupNotation()
850 expect(component.disableGrpNotationValue).toBeTruthy()
852 it('resetVms() of reference dataform', () => {
854 expect(component.referenceDataObject.vm).toBeNull
857 it('Clear cache ', () => {
858 component.clearCache()
859 expect(component.downloadData.reference['name']).toBe(undefined);
863 it('sholud reset group notification ', () => {
864 component.Sample['group-notation-type'] = "existing-group-name"
865 component.resetGroupNotation()
866 expect(component.disableGrpNotationValue).toBe(true);
869 it('sholud reset group notification if value does not match ', () => {
870 component.Sample['group-notation-type'] = "123"
871 component.resetGroupNotation()
872 expect(component.disableGrpNotationValue).toBe(false);
875 it('add identity group', () => {
876 component.referenceDataObject['template-id-list'] = undefined
877 component.templateId = "test"
878 component.addToIdentDrp()
879 expect(component.referenceDataObject['template-id-list'].length).toBe(1);
883 it('add identity group', () => {
886 expect(component.referenceDataObject.vm.length).toBe(0);
887 //expect(fileSaved).toBe(undefined)
889 it('data modified', () => {
891 component.dataModified()
893 component.referenceDataObject.vm = [1, 2]
894 expect(component.referenceDataObject.vm.length).toBe(2);
895 //expect(fileSaved).toBe(undefined)
898 it("should set values on action change ConfigScaleOut", () => {
899 component.actionChange(null, { valid: true });
901 expect(component.groupAnotationType.length).toBe(5)
903 it("shpukd return false if its very first action", () => {
904 component.actionChange(null,{ valid: true });
906 expect(component.disableGrpNotationValue).toBe(false)
908 it("sholud check no configuration actions", () => {
909 component.tempAllData = [
913 'vnf-type': "testVnf"
917 component.actionChange("Configure", { valid: true });
919 expect(component.nonConfigureAction).toBe(false)
922 it("should set values on action change when action is HealthCheck ", () => {
923 component.populateExistinAction("HealthCheck")
925 expect(component.deviceProtocols.length).toBe(4)
928 it("should set values on action change when action is UpgradeBackout", () => {
929 component.populateExistinAction("UpgradeBackout")
931 expect(component.deviceProtocols.length).toBe(3)
934 it("should set values on action change when action is OpenStack Actions", () => {
935 component.populateExistinAction("OpenStack Actions")
937 expect(component.deviceProtocols.length).toBe(2)
940 it("should set values on action change when action is Configure", () => {
941 component.tempAllData = [
945 'vnf-type': "testVnf"
949 component.populateExistinAction("Configure")
950 expect(component.referenceDataObject.scope['vnf-type']).toBe('testVnf')
953 it("shoukd clear vnf data ", () => {
954 component.clearVnfcData()
955 expect(component.Sample['vnfc-instance']).toBe('1')
957 it("shoudl showUpload", () => {
958 component.uploadTypes = [
960 value: 'Reference Data',
961 display: 'Sample Json Param File'
964 value: 'Mapping Data',
965 display: 'Sample Json Param File'
968 component.showUpload()
970 expect(component.selectedUploadType).toBe('Reference Data')
972 it("set vm instance", () => {
974 component.referenceDataObject.vm = [
979 component.setVmInstance(0)
980 expect(component.referenceDataObject.vm[0]['vm-instance']).toBe(1)
983 it("set vnfc type", () => {
984 // component.setVnfcType("test")
985 // expect(component.Sample['vnfc-type']).toBe("test");
987 it("getChange", () => {
988 // component.getChange("vnfType")
989 // expect(component.referenceDataObject.scope['vnfc-type']).toBe("");
991 it("idChange", () => {
992 component.idChange(null, { valid: true })
993 component.oldAction = "Configure"
994 expect(component.actionChanged).toBeFalsy()
996 it("idChange", () => {
997 component.oldAction = "Configure"
998 component.oldtemplateIdentifier = "id1"
999 component.templateIdentifier = "id1"
1000 component.idChange(null, { valid: true })
1001 expect(component.actionChanged).toBe(false)
1003 it('Should test deviceProtocolChange method', () => {
1004 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
1005 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
1006 component.deviceProtocolChange();
1007 expect(spy).toHaveBeenCalled()
1010 it('should test uplaod function', () => {
1011 let content = "Hello World";
1012 let data = new Blob([content], { type: 'text/plain' });
1013 let arrayOfBlob = new Array<Blob>();
1014 arrayOfBlob.push(data);
1015 let file = new File(arrayOfBlob, "Mock.XLS");
1016 let evnt = {target: {files: [file]}};
1017 component.upload(evnt);
1020 it('Should validatte fileChange method if file type is xml', async(() => {
1021 let reader = new FileReader();
1022 let content = "{data : 'Hello World'}";
1023 let data = new Blob([content], { type: 'text/plain' });
1024 let arrayOfBlob = new Array<Blob>();
1025 arrayOfBlob.push(data);
1026 let file = new File(arrayOfBlob, "Mock.XLS");
1027 let input = {target: {files: [file]}};
1029 component.fileChange(input);
1032 it('Should test openModel function to set proper values', () => {
1033 component.openModel(true, 'toShowMessage', 'title');
1034 expect(component.modalComponent.isShow).toBe(true);
1035 expect(component.modalComponent.message).toBe('toShowMessage');
1036 expect(component.modalComponent.title).toBe('title');