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;
52 let httpMock: HttpUtilService
53 //mockingthe data for mappingEditorService
62 "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" } },
64 "status": { code: "400", message: "success" }
71 class MockMappingService {
72 public latestAction; // = {"action":"Configure"}
81 downloadDataObject = {
94 referenceNameObjects = [
98 action: "StartApplication"
102 setTemplateMappingDataFromStore(data) {
111 setParamContent(data) {
114 setSessionParamData(data) {
118 saveLatestAction() { }
119 saveLatestIdentifier() { }
120 changeNavDownloadData() { }
121 changeNavAppData() { }
123 class MockreferenceDataObject { }
124 beforeEach(async(() => {
125 // originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
126 // jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
127 TestBed.configureTestingModule({
128 declarations: [ReferenceDataformComponent],
129 schemas: [NO_ERRORS_SCHEMA],
132 FormsModule, RouterTestingModule, HttpModule, NgbModule.forRoot(),
133 SharedModule.forRoot()
136 BuildDesignComponent, {
137 provide: MappingEditorService,
138 useClass: MockMappingService
142 NotificationService, {
143 provide: HttpUtilService,
148 }).compileComponents();
152 fixture = TestBed.createComponent(ReferenceDataformComponent);
153 component = fixture.componentInstance;
154 // component = new ReferenceDataformComponent(service)
155 fixture.detectChanges();
156 service = TestBed.get(MappingEditorService)
157 httpMock = TestBed.get(HttpUtilService)
158 sessionStorage.setItem('vnfParams', JSON.stringify({ vnfType: "test", vnfcType: "testVnfcType" }));
159 // component = new ReferenceDataformComponent(service)
161 it('should create reference component', () => {
162 expect(component).toBeTruthy();
164 it('Should load data from mapping sevice', () => {
166 expect(component.tempAllData.length).toBe(2)
168 it('testing init method', () => {
170 expect(component.tempAllData.length).toBe(2)
173 it("should set app data from service", () => {
175 expect(component.appData)
179 it("should set download from service", () => {
181 expect(component.downloadData)
185 it('Should reset form', () => {
186 component.resetForm()
187 expect(component.referenceDataObject['device-protocol']).toBe('')
188 expect(component.referenceDataObject['action-level']).toBe('vnf')
189 expect(component.referenceDataObject.template).toBe('Y')
190 expect(component.referenceDataObject['user-name']).toBe('')
191 expect(component.Sample['vnfc-type']).toBe('')
192 expect(component.refernceScopeObj.sourceType).toBe('')
193 expect(component.referenceDataObject['port-number']).toBe('')
195 it("prepare reference method at vnf level", () => {
197 component.referenceDataObject = {
199 'action-level': 'vnf',
206 'device-protocol': '',
211 component.vnfcIdentifier = '346';
212 component.prepareReferenceObject();
213 expect(component.referenceDataObject['action-level']).toBe("vnf")
216 it("prepare reference method at vnfc level", () => {
218 component.referenceDataObject = {
220 'action-level': 'vnf',
223 'vnfc-type-list': ['346']
227 'device-protocol': '',
232 component.vnfcIdentifier = '346';
233 component.prepareReferenceObject();
234 expect(component.referenceDataObject['action-level']).toBe("vnf")
237 it("prepare reference method at vnf and vnfc level", () => {
239 component.referenceDataObject = {
240 action: 'starttApplication',
241 'action-level': 'vnf',
244 'vnfc-type-list': ['346']
248 'device-protocol': 'ANSIBLE',
253 component.vnfcIdentifier = '346';
254 component.prepareReferenceObject();
256 expect(component.referenceDataObject['action-level']).toBe("vnf")
258 //deviceprotocols netconf
259 it("prepare reference method testing with netconf", () => {
261 component.referenceDataObject = {
262 action: 'starttApplication',
263 'action-level': 'vnf',
266 'vnfc-type-list': ['346']
270 'device-protocol': 'NETCONF-XML',
275 component.vnfcIdentifier = '346';
276 component.prepareReferenceObject();
277 expect(component.referenceDataObject['action-level']).toBe("vnf")
280 it("prepare reference method at template id list", () => {
282 component.referenceDataObject = {
283 action: 'ConfigScaleOut',
284 'action-level': 'vnf',
287 'vnfc-type-list': ['346']
291 'device-protocol': 'NETCONF-XML',
297 component.vnfcIdentifier = '346';
298 component.referenceDataObject['template-id-list'] = ['id1', 'id2']
300 component.prepareReferenceObject();
302 expect(component.referenceDataObject['action-level']).toBe("vnf")
304 it("prepare reference method at vnfc level", () => {
306 component.referenceDataObject = {
307 action: 'startApplication',
308 'action-level': 'vnfc',
311 'vnfc-type-list': ['346']
315 'device-protocol': '',
320 component.vnfcIdentifier = '346';
321 component.prepareReferenceObject();
322 expect(component.referenceDataObject['action-level']).toBe("vnf")
324 it("prepare reference method at vnf level", () => {
326 component.referenceDataObject = {
327 action: 'ConfigScaleOut',
328 'action-level': 'vnf',
331 'vnfc-type-list': ['346']
335 'device-protocol': '',
340 component.vnfcIdentifier = '346';
341 component.prepareReferenceObject();
342 expect(component.referenceDataObject['action-level']).toBe("vnf")
345 it('should create reference component', () => {
347 expect(component).toBeTruthy();
349 it('configscaleout test', () => {
350 service.latestAction = {
351 action: 'ConfigScaleOut',
352 'action-level': 'vnf',
359 'device-protocol': '',
364 service.referenceNameObjects = [
368 action: "StartApplication"
372 expect(component.referenceDataObject.action).toBe("ConfigScaleOut");
376 it('shoud add vms with template id when the acti0on is configscaleout ', () => {
377 component.referenceDataObject = {
378 action: 'ConfigScaleOut',
379 'action-level': 'vnf',
382 'vnfc-type-list': ['346']
395 'device-protocol': '',
401 component.refernceScopeObj.from = "3"
404 expect(component.referenceDataObject.vm.length).toBe(4);
406 it('shoud add vms with template id when the action is not configscaleout', () => {
407 component.referenceDataObject = {
409 'action-level': 'vnf',
412 'vnfc-type-list': ['346']
425 'device-protocol': '',
431 component.refernceScopeObj.from = "3"
434 expect(component.referenceDataObject.vm[0]['template-id']).toBe(undefined);
437 it('testing ngdestroy', () => {
438 this.uploadFileName = 'testing'
439 component.ngOnDestroy()
440 expect(component.uploadedDataArray.length).toBe(0);
441 expect(component.uploadFileName).toBe('');
443 it('should validate numbers', () => {
445 component.numberValidation(1)
446 expect(component.numberOfVmTest).toBe(true);
450 it('should validate numbers if input is string', () => {
452 component.numberValidation('test')
453 expect(component.numberOfVmTest).toBe(false);
457 it('testing check if elements exixts in an array', () => {
459 let x = component.checkIfelementExistsInArray(2, [1, 2, 3])
460 expect(x).toBeTruthy();
463 it('should set action in session if type is action', () => {
465 component.updateSessionValues("test event for action", "action")
467 expect(sessionStorage.getItem('action')).toBe('test event for action');
469 it('should set action in session if type is vnfType', () => {
471 component.updateSessionValues("test event for vnfType", "vnfType")
473 expect(sessionStorage.getItem('vnfType')).toBe('test event for vnfType');
476 it('should add vnfs on to reference Object ', () => {
478 component.referenceDataObject = {
480 'action-level': 'vnf',
483 'vnfc-type-list': ['346']
496 'device-protocol': '',
502 component.addVnfcData(0)
504 expect(component.referenceDataObject.vm[0].vnfc.length).toBe(2);
507 it("should remove feature from the reference object ", () => {
508 component.referenceDataObject = {
510 'action-level': 'vnf',
513 'vnfc-type-list': ['346']
533 'device-protocol': '',
539 component.removeFeature(0, 0, 0)
541 expect(component.referenceDataObject.vm.length).toBe(1)
544 it("remove templateIds vm if action is confiogscaleout", () => {
545 component.referenceDataObject = {
546 action: 'ConfigScaleOut',
547 'action-level': 'vnf',
550 'vnfc-type-list': ['346']
555 "template-id": "klmklj",
559 "vnfc-instance": "1",
560 "vnfc-function-code": "klkl",
561 "ipaddress-v4-oam-vip": "",
562 "group-notation-type": "",
563 "group-notation-value": "",
568 "template-id": "test 12",
572 "vnfc-instance": "1",
573 "vnfc-function-code": "klkl",
574 "ipaddress-v4-oam-vip": "",
575 "group-notation-type": "",
576 "group-notation-value": "",
582 'device-protocol': '',
588 component.removeFeature(0, 0, 'test 12')
590 //expect(component.referenceDataObject.vm.length).toBe(2)
594 it("should add capabilities", () => {
595 component.uploadedDataArray = [
598 component.addVmCapabilitiesData()
600 expect(component.tempAllData.length).toBe(3)
602 it("should add capabilities", () => {
603 service.latestAction = {
604 action: 'OpenStack Actions',
605 'action-level': 'vnf',
612 'device-protocol': '',
617 service.referenceNameObjects = [
621 action: "StartApplication"
625 component.prepareReferenceObject();
627 expect(component.referenceDataObject['action-level']).toBe("vnf")
630 it("should add capabilities", () => {
631 service.latestAction = {
632 action: 'OpenStack Actions',
633 'action-level': 'vnf',
640 'device-protocol': '',
646 component.referenceDataObject.action = "OpenStack Actions"
647 service.referenceNameObjects = [
651 action: "StartApplication"
655 component.prepareReferenceObject();
657 expect(component.referenceDataObject['action-level']).toBe("vnf")
660 it("should switch vms if action is configscaleout", () => {
662 component.currentAction = "ConfigScaleOut"
663 service.latestAction = {
664 action: 'OpenStack Actions',
665 'action-level': 'vnf',
672 'device-protocol': '',
677 service.referenceNameObjects = [
681 action: "StartApplication"
685 component.tempAllData = [
687 action: "ConfigScaleOut",
692 component.prepareReferenceObject();
694 expect(component.referenceDataObject.vm.length).toBe(2)
696 it("should switch vms if action is configscaleout", () => {
698 component.currentAction = "ConfigScaleOut"
699 service.latestAction = {
700 action: 'OpenStack Actions',
701 'action-level': 'vnf',
708 'device-protocol': '',
713 service.referenceNameObjects = [
717 action: "StartApplication"
721 component.tempAllData = [
723 action: "startAplicaton"
727 component.prepareReferenceObject();
729 expect(component.referenceDataObject.vm.length).toBe(0)
731 it('shoud show template identifier when action is config scaleout', () => {
732 let data = 'ConfigScaleOut'
733 component.toggleIdentifier(data)
734 expect(component.isConfigScaleOut).toBe(true);
736 it('shoud show template identifier when action is config scaleout', () => {
737 let data = 'startApplication'
738 component.toggleIdentifier(data)
739 expect(component.isConfigScaleOut).toBe(false);
742 it('Should call get artifact', () => {
744 service.referenceNameObjects = undefined
746 expect(component.tempAllData.length).toBe(2)
749 it('Should call get artifact', () => {
750 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
751 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
752 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
754 component.getArtifact()
756 expect(spy).toHaveBeenCalled();
757 expect(component.tempAllData.length).toBe(3);
760 it('Save file - should not process if action is null ', () => {
761 component.referenceDataObject.action = ""
762 let fileSaved = component.save({}, true)
763 expect(fileSaved).toBe(undefined)
765 it('Save file - should not process if device protocol is null ', () => {
766 component.referenceDataObject.action = "Configure"
767 component.referenceDataObject['device-protocol'] = ''
768 let fileSaved = component.save({}, true)
769 expect(fileSaved).toBe(undefined)
771 it('Save file - should not process if device protocol is null ', () => {
772 component.referenceDataObject.action = "Configure"
773 component.referenceDataObject['device-protocol'] = "test"
774 component.downloadData.template.templateData = { "test": "test" }
775 component.downloadData.template.nameValueData = { "test": "test" }
776 component.downloadData.pd.pdData = "test"
777 let fileSaved = component.save({}, true)
778 //expect(fileSaved).toBe(undefined)
781 it('Save to appc file - should not process if action is null ', () => {
782 component.referenceDataObject.action = "";
783 component.referenceDataObject.scope['vnf-type'] = '';
784 component.tempAllData = [{
787 'vnf-type': "testVnf"
790 action: "StartApplication",
792 'vnf-type': "testVnf"
796 let fileSaved = component.saveToAppc();
797 expect(fileSaved).toBe(undefined)
799 it('Save to app cfile - should not process if device protocol is null ', () => {
800 component.referenceDataObject['device-protocol'] = ""
801 component.referenceDataObject.action = "Configure"
802 component.tempAllData = [{
805 'vnf-type': "testVnf"
808 action: "StartApplication",
810 'vnf-type': "testVnf"
814 let fileSaved = component.saveToAppc();
815 expect(fileSaved).toBe(undefined)
817 it('Save to appc file - should not process if device protocol is null ', () => {
818 component.tempAllData = [
822 'vnf-type': "testVnf"
826 component.referenceDataObject.action = "Configure"
827 component.referenceDataObject['device-protocol'] = "test"
828 component.appData.template.templateData = { "test": "test" }
829 component.appData.template.nameValueData = { "test": "test" }
830 component.appData.pd = { "test": "test" }
831 component.actionChanged = true
832 component.currentAction = "COnfigure"
833 let fileSaved = component.saveToAppc();
834 expect(fileSaved).toBe(undefined)
837 // it('uploadfile ', () => { let files = { 0: {name:'foo.XLS', size:
838 // 500001} }; var mockEVet = { target:{files:files} }
839 // component.upload(mockEVet) //expect(fileSaved).toBe(undefined) })
841 it('validateTempAllData() of reference dataform', () => {
842 component.validateTempAllData()
844 it('retriveFromAppc() of reference dataform', () => {
845 sessionStorage.setItem('updateParams', JSON.stringify({ vnf: 123, userID: 'testUser' }))
846 component.retriveFromAppc()
847 expect(component.noCacheData).toBeFalsy()
849 it('retriveFromAppc() of reference dataform for false', () => {
850 sessionStorage.setItem('updateParams', 'undefined')
851 component.retriveFromAppc()
852 expect(component.noCacheData).toBeTruthy()
855 it('resetGroupNotation() of reference dataform for false case', () => {
856 component.resetGroupNotation()
857 expect(component.disableGrpNotationValue).toBeFalsy()
859 it('resetGroupNotation() of reference dataform for true case', () => {
860 component.Sample['group-notation-type'] = "existing-group-name"
861 component.resetGroupNotation()
862 expect(component.disableGrpNotationValue).toBeTruthy()
864 it('resetVms() of reference dataform', () => {
866 expect(component.referenceDataObject.vm).toBeNull
869 it('Clear cache ', () => {
870 component.clearCache()
871 expect(component.downloadData.reference['name']).toBe(undefined);
875 it('sholud reset group notification ', () => {
876 component.Sample['group-notation-type'] = "existing-group-name"
877 component.resetGroupNotation()
878 expect(component.disableGrpNotationValue).toBe(true);
881 it('sholud reset group notification if value does not match ', () => {
882 component.Sample['group-notation-type'] = "123"
883 component.resetGroupNotation()
884 expect(component.disableGrpNotationValue).toBe(false);
887 it('add identity group', () => {
888 component.referenceDataObject['template-id-list'] = undefined
889 component.templateId = "test"
890 component.addToIdentDrp()
891 expect(component.referenceDataObject['template-id-list'].length).toBe(1);
895 it('add identity group', () => {
898 expect(component.referenceDataObject.vm.length).toBe(0);
899 //expect(fileSaved).toBe(undefined)
901 it('data modified', () => {
903 component.dataModified()
905 component.referenceDataObject.vm = [1, 2]
906 expect(component.referenceDataObject.vm.length).toBe(2);
907 //expect(fileSaved).toBe(undefined)
910 it("should set values on action change ConfigScaleOut", () => {
911 component.actionChange('ConfigScaleOut', { valid: true });
913 expect(component.groupAnotationType.length).toBe(5)
915 it("shpukd return false if its very first action", () => {
916 component.actionChange(null,{ valid: true });
918 expect(component.disableGrpNotationValue).toBe(false)
920 it("sholud check no configuration actions", () => {
921 component.tempAllData = [
925 'vnf-type': "testVnf"
929 component.actionChange("Configure", { valid: true });
931 expect(component.nonConfigureAction).toBe(false)
934 it("should set values on action change when action is HealthCheck ", () => {
935 component.populateExistinAction("HealthCheck")
937 expect(component.deviceProtocols.length).toBe(4)
940 it("should set values on action change when action is UpgradeBackout", () => {
941 component.populateExistinAction("UpgradeBackout")
943 expect(component.deviceProtocols.length).toBe(3)
946 it("should set values on action change when action is OpenStack Actions", () => {
947 component.populateExistinAction("OpenStack Actions")
949 expect(component.deviceProtocols.length).toBe(2)
952 it("should set values on action change when action is Configure", () => {
953 component.tempAllData = [
957 'vnf-type': "testVnf"
961 component.populateExistinAction("Configure")
962 expect(component.referenceDataObject.scope['vnf-type']).toBe('testVnf')
965 it("shoukd clear vnf data ", () => {
966 component.clearVnfcData()
967 expect(component.Sample['vnfc-instance']).toBe('1')
969 it("shoudl showUpload", () => {
970 component.uploadTypes = [
972 value: 'Reference Data',
973 display: 'Sample Json Param File'
976 value: 'Mapping Data',
977 display: 'Sample Json Param File'
980 component.showUpload()
982 expect(component.selectedUploadType).toBe('Reference Data')
984 it("set vm instance", () => {
986 component.referenceDataObject.vm = [
991 component.setVmInstance(0)
992 expect(component.referenceDataObject.vm[0]['vm-instance']).toBe(1)
995 it("set vnfc type", () => {
996 // component.setVnfcType("test")
997 // expect(component.Sample['vnfc-type']).toBe("test");
999 it("getChange", () => {
1000 // component.getChange("vnfType")
1001 // expect(component.referenceDataObject.scope['vnfc-type']).toBe("");
1003 it("idChange", () => {
1004 component.idChange(null, { valid: true })
1005 component.oldAction = "Configure"
1006 expect(component.actionChanged).toBeFalsy()
1008 it("idChange", () => {
1009 component.oldAction = "Configure"
1010 component.oldtemplateIdentifier = "id1"
1011 component.templateIdentifier = "id1"
1012 component.idChange(null, { valid: true })
1013 expect(component.actionChanged).toBe(false)
1015 it('Should test deviceProtocolChange method', () => {
1016 let spy = spyOn(BuildDesignComponent.prototype, 'getRefData');
1017 let refData = { "action": "Configure", "vnf-type": "test 1", "device-protocol": "ANSIBLE" };
1018 component.deviceProtocolChange();
1019 expect(spy).toHaveBeenCalled()
1022 it('should test uplaod function', () => {
1023 let content = "Hello World";
1024 let data = new Blob([content], { type: 'text/plain' });
1025 let arrayOfBlob = new Array<Blob>();
1026 arrayOfBlob.push(data);
1027 let file = new File(arrayOfBlob, "Mock.XLS");
1028 let evnt = {target: {files: [file]}};
1029 component.upload(evnt);
1032 it('Should validatte fileChange method if file type is xml', async(() => {
1033 let reader = new FileReader();
1034 let content = "{data : 'Hello World'}";
1035 let data = new Blob([content], { type: 'text/plain' });
1036 let arrayOfBlob = new Array<Blob>();
1037 arrayOfBlob.push(data);
1038 let file = new File(arrayOfBlob, "Mock.XLS");
1039 let input = {target: {files: [file]}};
1041 component.fileChange(input);
1044 it('should test validateVnfcName function with empty name value', ()=>{
1045 component.validateVnfcName('');
1046 expect(component.errorMessage).toBe('');
1047 expect(component.invalid).toBe(true);
1050 it('should test validateVnfcName function with name value leading and trailing white spaces', ()=>{
1051 component.validateVnfcName(' name ');
1052 expect(component.errorMessage).toBe('Leading and trailing spaces are not allowed');
1053 expect(component.invalid).toBe(true);
1056 it('should test validateVnfcName function with name including more than one space', ()=>{
1057 component.validateVnfcName('na me');
1058 expect(component.errorMessage).toBe('More than one space is not allowed in VNFC Type');
1059 expect(component.invalid).toBe(true);
1062 it('should test validateVnfcName function with name length greated than 150', ()=>{
1063 component.validateVnfcName('namenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenanamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenanamenamnamenamename');
1064 expect(component.errorMessage).toBe('VNFC Type should be of minimum one character and maximum 50 character');
1065 expect(component.invalid).toBe(true);
1068 it('should test validateVnfcName function with valid name value', ()=>{
1069 component.validateVnfcName('name');
1070 expect(component.errorMessage).toBe('');
1071 expect(component.invalid).toBe(false);
1074 it('should test displayHideVnfc function', inject([MappingEditorService], (service: MappingEditorService) => {
1075 component.referenceDataObject = {
1076 action: 'ConfigScaleOut',
1077 'action-level': 'vnf',
1080 'vnfc-type-list': ['346']
1084 'device-protocol': '',
1089 service.newObject = { vnfc: false};
1090 component.displayHideVnfc();
1091 expect(component.vnfcIdentifier).toBe('346');
1094 it('should test displayHideVnfc function vnfc is true', inject([MappingEditorService], (service: MappingEditorService) => {
1095 component.referenceDataObject = {
1096 action: 'ConfigScaleOut',
1097 'action-level': 'vnf',
1100 'vnfc-type-list': ['346']
1104 'device-protocol': '',
1109 service.newObject = { vnfc: true};
1110 component.displayHideVnfc();
1111 expect(component.vnfcIdentifier).toBe(true);
1114 it('should test validateDataAndSaveToAppc function', ()=>{
1115 component.tempAllData = [{
1116 action: "Configure",
1118 'vnf-type': "testVnf"
1121 action: "StartApplication",
1123 'vnf-type': "testVnf"
1127 component.actionChanged = true;
1128 component.currentAction = 'Config';
1129 let spy = spyOn(ReferenceDataformComponent.prototype, 'populateExistinAction');
1130 component.validateDataAndSaveToAppc(true, {}, {});
1131 expect(spy).toHaveBeenCalled();
1132 expect(component.referenceDataObject.action).toBe('Config')
1136 // afterEach(function() {
1137 // jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;