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.prepareReferenceObject();
209 expect(component.referenceDataObject['action-level']).toBe("vnf")
212 it("prepare reference method at vnfc level", () => {
214 component.referenceDataObject = {
216 'action-level': 'vnf',
219 'vnfc-type-list': ['346']
223 'device-protocol': '',
229 component.prepareReferenceObject();
230 expect(component.referenceDataObject['action-level']).toBe("vnfc")
233 it("prepare reference method at vnf and vnfc level", () => {
235 component.referenceDataObject = {
236 action: 'starttApplication',
237 'action-level': 'vnf',
240 'vnfc-type-list': ['346']
244 'device-protocol': 'ANSIBLE',
249 component.prepareReferenceObject();
251 expect(component.referenceDataObject['action-level']).toBe("vnf")
253 //deviceprotocols netconf
254 it("prepare reference method testing with netconf", () => {
256 component.referenceDataObject = {
257 action: 'starttApplication',
258 'action-level': 'vnf',
261 'vnfc-type-list': ['346']
265 'device-protocol': 'NETCONF-XML',
271 component.prepareReferenceObject();
272 expect(component.referenceDataObject['action-level']).toBe("vnf")
275 it("prepare reference method at template id list", () => {
277 component.referenceDataObject = {
278 action: 'ConfigScaleOut',
279 'action-level': 'vnf',
282 'vnfc-type-list': ['346']
286 'device-protocol': 'NETCONF-XML',
293 component.referenceDataObject['template-id-list'] = ['id1', 'id2']
295 component.prepareReferenceObject();
297 expect(component.referenceDataObject['action-level']).toBe("vnf")
299 it("prepare reference method at vnfc level", () => {
301 component.referenceDataObject = {
302 action: 'startApplication',
303 'action-level': 'vnfc',
306 'vnfc-type-list': ['346']
310 'device-protocol': '',
315 component.prepareReferenceObject();
316 expect(component.referenceDataObject['action-level']).toBe("vnf")
318 it("prepare reference method at vnf level", () => {
320 component.referenceDataObject = {
321 action: 'ConfigScaleOut',
322 'action-level': 'vnf',
325 'vnfc-type-list': ['346']
329 'device-protocol': '',
334 component.prepareReferenceObject();
335 expect(component.referenceDataObject['action-level']).toBe("vnf")
338 it('should create reference component', () => {
340 expect(component).toBeTruthy();
342 it('configscaleout test', () => {
343 service.latestAction = {
344 action: 'ConfigScaleOut',
345 'action-level': 'vnf',
352 'device-protocol': '',
357 service.referenceNameObjects = [
361 action: "StartApplication"
365 expect(component.referenceDataObject.action).toBe("ConfigScaleOut");
369 it('shoud add vms with template id when the acti0on is configscaleout ', () => {
370 component.referenceDataObject = {
371 action: 'ConfigScaleOut',
372 'action-level': 'vnf',
375 'vnfc-type-list': ['346']
388 'device-protocol': '',
394 component.refernceScopeObj.from = "3"
397 expect(component.referenceDataObject.vm.length).toBe(4);
399 it('shoud add vms with template id when the action is not configscaleout', () => {
400 component.referenceDataObject = {
402 'action-level': 'vnf',
405 'vnfc-type-list': ['346']
418 'device-protocol': '',
424 component.refernceScopeObj.from = "3"
427 expect(component.referenceDataObject.vm[0]['template-id']).toBe(undefined);
430 it('testing ngdestroy', () => {
431 this.uploadFileName = 'testing'
432 component.ngOnDestroy()
433 expect(component.uploadedDataArray.length).toBe(0);
434 expect(component.uploadFileName).toBe('');
436 it('should validate numbers', () => {
438 component.numberValidation(1)
439 expect(component.numberOfVmTest).toBe(true);
443 it('should validate numbers if input is string', () => {
445 component.numberValidation('test')
446 expect(component.numberOfVmTest).toBe(false);
450 it('testing check if elements exixts in an array', () => {
452 let x = component.checkIfelementExistsInArray(2, [1, 2, 3])
453 expect(x).toBeTruthy();
456 it('should set action in session if type is action', () => {
458 component.updateSessionValues("test event for action", "action")
460 expect(sessionStorage.getItem('action')).toBe('test event for action');
462 it('should set action in session if type is vnfType', () => {
464 component.updateSessionValues("test event for vnfType", "vnfType")
466 expect(sessionStorage.getItem('vnfType')).toBe('test event for vnfType');
469 it('should add vnfs on to reference Object ', () => {
471 component.referenceDataObject = {
473 'action-level': 'vnf',
476 'vnfc-type-list': ['346']
489 'device-protocol': '',
495 component.addVnfcData(0)
497 expect(component.referenceDataObject.vm[0].vnfc.length).toBe(2);
500 it("should remove feature from the reference object ", () => {
501 component.referenceDataObject = {
503 'action-level': 'vnf',
506 'vnfc-type-list': ['346']
526 'device-protocol': '',
532 component.removeFeature(0, 0, 0)
534 expect(component.referenceDataObject.vm.length).toBe(1)
537 it("remove templateIds vm if action is confiogscaleout", () => {
538 component.referenceDataObject = {
539 action: 'ConfigScaleOut',
540 'action-level': 'vnf',
543 'vnfc-type-list': ['346']
548 "template-id": "klmklj",
552 "vnfc-instance": "1",
553 "vnfc-function-code": "klkl",
554 "ipaddress-v4-oam-vip": "",
555 "group-notation-type": "",
556 "group-notation-value": "",
561 "template-id": "test 12",
565 "vnfc-instance": "1",
566 "vnfc-function-code": "klkl",
567 "ipaddress-v4-oam-vip": "",
568 "group-notation-type": "",
569 "group-notation-value": "",
575 'device-protocol': '',
581 component.removeFeature(0, 0, 'test 12')
583 //expect(component.referenceDataObject.vm.length).toBe(2)
587 it("should add capabilities", () => {
588 component.uploadedDataArray = [
591 component.addVmCapabilitiesData()
593 expect(component.tempAllData.length).toBe(3)
595 it("should add capabilities", () => {
596 service.latestAction = {
597 action: 'OpenStack Actions',
598 'action-level': 'vnf',
605 'device-protocol': '',
610 service.referenceNameObjects = [
614 action: "StartApplication"
618 component.prepareReferenceObject();
620 expect(component.referenceDataObject['action-level']).toBe("vnf")
623 it("should add capabilities", () => {
624 service.latestAction = {
625 action: 'OpenStack Actions',
626 'action-level': 'vnf',
633 'device-protocol': '',
639 component.referenceDataObject.action = "OpenStack Actions"
640 service.referenceNameObjects = [
644 action: "StartApplication"
648 component.prepareReferenceObject();
650 expect(component.referenceDataObject['action-level']).toBe("vnf")
653 it("should switch vms if action is configscaleout", () => {
655 component.currentAction = "ConfigScaleOut"
656 service.latestAction = {
657 action: 'OpenStack Actions',
658 'action-level': 'vnf',
665 'device-protocol': '',
670 service.referenceNameObjects = [
674 action: "StartApplication"
678 component.tempAllData = [
680 action: "ConfigScaleOut",
685 component.prepareReferenceObject();
687 expect(component.referenceDataObject.vm.length).toBe(2)
689 it("should switch vms if action is configscaleout", () => {
691 component.currentAction = "ConfigScaleOut"
692 service.latestAction = {
693 action: 'OpenStack Actions',
694 'action-level': 'vnf',
701 'device-protocol': '',
706 service.referenceNameObjects = [
710 action: "StartApplication"
714 component.tempAllData = [
716 action: "startAplicaton"
720 component.prepareReferenceObject();
722 expect(component.referenceDataObject.vm.length).toBe(0)
724 it('shoud show template identifier when action is config scaleout', () => {
725 let data = 'ConfigScaleOut'
726 component.toggleIdentifier(data)
727 expect(component.isConfigScaleOut).toBe(true);
729 it('shoud show template identifier when action is config scaleout', () => {
730 let data = 'startApplication'
731 component.toggleIdentifier(data)
732 expect(component.isConfigScaleOut).toBe(false);
735 it('Should call get artifact', () => {
737 service.referenceNameObjects = undefined
739 expect(component.tempAllData.length).toBe(2)
742 it('Should call get artifact', () => {
743 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
744 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
745 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
747 component.getArtifact()
749 expect(spy).toHaveBeenCalled();
750 expect(component.tempAllData.length).toBe(3);
753 it('Save file - should not process if action is null ', () => {
754 component.referenceDataObject.action = ""
755 let fileSaved = component.save({}, true)
756 expect(fileSaved).toBe(undefined)
758 it('Save file - should not process if device protocol is null ', () => {
759 component.referenceDataObject.action = "Configure"
760 component.referenceDataObject['device-protocol'] = ''
761 let fileSaved = component.save({}, true)
762 expect(fileSaved).toBe(undefined)
764 it('Save file - should not process if device protocol is null ', () => {
765 component.referenceDataObject.action = "Configure"
766 component.referenceDataObject['device-protocol'] = "test"
767 component.downloadData.template.templateData = { "test": "test" }
768 component.downloadData.template.nameValueData = { "test": "test" }
769 component.downloadData.pd.pdData = "test"
770 let fileSaved = component.save({}, true)
771 //expect(fileSaved).toBe(undefined)
774 it('Save to appc file - should not process if action is null ', () => {
775 component.referenceDataObject.action = ""
776 let fileSaved = component.saveToAppc();
777 expect(fileSaved).toBe(undefined)
779 it('Save to app cfile - should not process if device protocol is null ', () => {
780 component.referenceDataObject['device-protocol'] = ""
781 component.referenceDataObject.action = "Configure"
782 let fileSaved = component.saveToAppc();
783 expect(fileSaved).toBe(undefined)
785 it('Save to appc file - should not process if device protocol is null ', () => {
786 component.referenceDataObject.action = "Configure"
787 component.referenceDataObject['device-protocol'] = "test"
788 component.appData.template.templateData = { "test": "test" }
789 component.appData.template.nameValueData = { "test": "test" }
790 component.appData.pd = { "test": "test" }
791 component.actionChanged = true
792 component.currentAction = "COnfigure"
793 let fileSaved = component.saveToAppc();
794 //expect(fileSaved).toBe(undefined)
797 // it('uploadfile ', () => { let files = { 0: {name:'foo.XLS', size:
798 // 500001} }; var mockEVet = { target:{files:files} }
799 // component.upload(mockEVet) //expect(fileSaved).toBe(undefined) })
801 it('downloadTemplate() of reference dataform', () => {
802 component.downloadTemplate()
805 it('downloadNameValue() of reference dataform', () => {
806 component.downloadNameValue()
809 it('downloadPd() of reference dataform', () => {
810 component.downloadPd()
812 it('validateTempAllData() of reference dataform', () => {
813 component.validateTempAllData()
815 it('retriveFromAppc() of reference dataform', () => {
816 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
817 component.retriveFromAppc()
818 expect(component.noCacheData).toBeFalsy()
820 it('retriveFromAppc() of reference dataform for false', () => {
821 sessionStorage.setItem('updateParams', 'undefined')
822 component.retriveFromAppc()
823 expect(component.noCacheData).toBeTruthy()
825 it(' cloneMessage(servermessage) of reference dataform', () => {
826 let servermessage = {
829 component.cloneMessage(servermessage)
832 it('resetGroupNotation() of reference dataform for false case', () => {
833 component.resetGroupNotation()
834 expect(component.disableGrpNotationValue).toBeFalsy()
836 it('resetGroupNotation() of reference dataform for true case', () => {
837 component.Sample['group-notation-type'] = "existing-group-name"
838 component.resetGroupNotation()
839 expect(component.disableGrpNotationValue).toBeTruthy()
841 it('resetVms() of reference dataform', () => {
843 expect(component.referenceDataObject.vm).toBeNull
846 it('Clear cache ', () => {
847 component.clearCache()
848 expect(component.downloadData.reference['name']).toBe(undefined);
852 it('sholud reset group notification ', () => {
853 component.Sample['group-notation-type'] = "existing-group-name"
854 component.resetGroupNotation()
855 expect(component.disableGrpNotationValue).toBe(true);
858 it('sholud reset group notification if value does not match ', () => {
859 component.Sample['group-notation-type'] = "123"
860 component.resetGroupNotation()
861 expect(component.disableGrpNotationValue).toBe(false);
864 it('add identity group', () => {
865 component.referenceDataObject['template-id-list'] = undefined
866 component.templateId = "test"
867 component.addToIdentDrp()
868 expect(component.referenceDataObject['template-id-list'].length).toBe(1);
872 it('add identity group', () => {
875 expect(component.referenceDataObject.vm.length).toBe(0);
876 //expect(fileSaved).toBe(undefined)
878 it('data modified', () => {
880 component.dataModified()
882 component.referenceDataObject.vm = [1, 2]
883 expect(component.referenceDataObject.vm.length).toBe(2);
884 //expect(fileSaved).toBe(undefined)
887 it("should set values on action change ConfigScaleOut", () => {
888 component.actionChange(null, { valid: true });
890 expect(component.groupAnotationType.length).toBe(5)
892 it("shpukd return false if its very first action", () => {
893 component.actionChange(null,{ valid: true });
895 expect(component.disableGrpNotationValue).toBe(false)
897 it("sholud check no configuration actions", () => {
898 component.tempAllData = [
902 'vnf-type': "testVnf"
906 component.actionChange(null, { valid: true });
908 expect(component.nonConfigureAction).toBe(false)
911 it("should set values on action change when action is HealthCheck ", () => {
912 component.populateExistinAction("HealthCheck")
914 expect(component.deviceProtocols.length).toBe(4)
917 it("should set values on action change when action is UpgradeBackout", () => {
918 component.populateExistinAction("UpgradeBackout")
920 expect(component.deviceProtocols.length).toBe(3)
923 it("should set values on action change when action is OpenStack Actions", () => {
924 component.populateExistinAction("OpenStack Actions")
926 expect(component.deviceProtocols.length).toBe(2)
929 it("should set values on action change when action is Configure", () => {
930 component.tempAllData = [
934 'vnf-type': "testVnf"
938 component.populateExistinAction("Configure")
939 expect(component.referenceDataObject.scope['vnf-type']).toBe('testVnf')
942 it("shoukd clear vnf data ", () => {
943 component.clearVnfcData()
944 expect(component.Sample['vnfc-instance']).toBe('1')
946 it("shoudl showUpload", () => {
947 component.uploadTypes = [
949 value: 'Reference Data',
950 display: 'Sample Json Param File'
953 value: 'Mapping Data',
954 display: 'Sample Json Param File'
957 component.showUpload()
959 expect(component.selectedUploadType).toBe('Reference Data')
961 it("set vm instance", () => {
963 component.referenceDataObject.vm = [
968 component.setVmInstance(0)
969 expect(component.referenceDataObject.vm[0]['vm-instance']).toBe(1)
972 it("set vnfc type", () => {
973 // component.setVnfcType("test")
974 expect(component.Sample['vnfc-type']).toBe("test");
976 it("getChange", () => {
977 // component.getChange("vnfType")
978 expect(component.referenceDataObject.scope['vnfc-type']).toBe("");
980 it("idChange", () => {
981 component.idChange(null, { valid: true })
982 component.oldAction = "Configure"
983 expect(component.actionChanged).toBeFalsy()
985 it("idChange", () => {
986 component.oldAction = "Configure"
987 component.oldtemplateIdentifier = "id1"
988 component.templateIdentifier = "id1"
989 component.idChange(null, { valid: true })
990 expect(component.actionChanged).toBe(true)
992 it('Should test deviceProtocolChange method', () => {
993 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
994 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
995 component.deviceProtocolChange();
996 expect(spy).toHaveBeenCalled()
999 it('should test uplaod function', () => {
1000 let content = "Hello World";
1001 let data = new Blob([content], { type: 'text/plain' });
1002 let arrayOfBlob = new Array<Blob>();
1003 arrayOfBlob.push(data);
1004 let file = new File(arrayOfBlob, "Mock.XLS");
1005 let evnt = {target: {files: [file]}};
1006 component.upload(evnt);
1009 it('Should validatte fileChange method if file type is xml', async(() => {
1010 let reader = new FileReader();
1011 let content = "{data : '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 input = {target: {files: [file]}};
1018 component.fileChange(input);
1021 it('Should test openModel function to set proper values', () => {
1022 component.openModel(true, 'toShowMessage', 'title');
1023 expect(component.modalComponent.isShow).toBe(true);
1024 expect(component.modalComponent.message).toBe('toShowMessage');
1025 expect(component.modalComponent.title).toBe('title');