Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
Arundathi Patil | 50883a6 | 2018-07-31 14:38:10 +0530 | [diff] [blame] | 5 | |
| 6 | Modification Copyright (C) 2018 IBM. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 7 | =================================================================== |
| 8 | |
| 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 |
| 13 | |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 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. |
| 21 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 22 | ============LICENSE_END============================================ |
| 23 | */ |
| 24 | |
| 25 | /* tslint:disable:no-unused-variable */ |
| 26 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; |
Mohamed Asgar Samiulla(ma926a) | 8ac6f16 | 2018-03-08 14:54:47 +0530 | [diff] [blame] | 27 | import {NO_ERRORS_SCHEMA} from '@angular/core'; |
| 28 | import {FormsModule} from '@angular/forms'; |
| 29 | import {NotificationService} from '../../shared/services/notification.service'; |
| 30 | import {ParamShareService} from '../../shared/services/paramShare.service'; |
| 31 | import {MappingEditorService} from '../../shared/services/mapping-editor.service'; |
| 32 | import {ModalComponent} from '../../shared/modal/modal.component'; |
| 33 | import {DialogService} from 'ng2-bootstrap-modal'; |
| 34 | import {ConfirmComponent} from '../../shared/confirmModal/confirm.component'; |
| 35 | import {RouterTestingModule} from '@angular/router/testing'; |
| 36 | import {HttpUtilService} from '../../shared/services/httpUtil/http-util.service'; |
| 37 | import {UtilityService} from '../../shared/services/utilityService/utility.service'; |
| 38 | |
| 39 | import {NotificationsService} from 'angular2-notifications'; |
| 40 | import {HomeComponent} from '../../home/home/home.component'; |
| 41 | import {LogoutComponent} from '../../shared/components/logout/logout.component'; |
| 42 | import {HelpComponent} from '../../shared/components/help/help/help.component'; |
| 43 | import {AboutUsComponent} from '../../about-us/aboutus.component'; |
| 44 | import {TestComponent} from '../../test/test.component'; |
| 45 | import {HttpModule} from '@angular/http'; |
| 46 | import { NgProgress } from 'ngx-progressbar'; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 47 | |
| 48 | import {BuildDesignComponent} from './build-artifacts.component'; |
| 49 | |
| 50 | describe('BuildDesignComponent', () => { |
| 51 | let component: BuildDesignComponent; |
| 52 | let fixture: ComponentFixture<BuildDesignComponent>; |
Mohamed Asgar Samiulla(ma926a) | 8ac6f16 | 2018-03-08 14:54:47 +0530 | [diff] [blame] | 53 | const routes = [ |
| 54 | { |
| 55 | path: 'home', |
| 56 | component: HomeComponent |
| 57 | }, { |
| 58 | path: 'vnfs', |
| 59 | loadChildren: './vnfs/vnfs.module#VnfsModule' |
| 60 | }, { |
| 61 | path: 'test', |
| 62 | component: TestComponent |
| 63 | }, |
| 64 | { |
| 65 | path: 'help', |
| 66 | component: HelpComponent |
| 67 | }, { |
| 68 | path: 'aboutUs', |
| 69 | component: AboutUsComponent |
| 70 | }, { |
| 71 | path: 'logout', |
| 72 | component: LogoutComponent |
| 73 | }, { |
| 74 | path: '', |
| 75 | redirectTo: '/home', |
| 76 | pathMatch: 'full' |
| 77 | } |
| 78 | ]; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 79 | beforeEach(async(() => { |
| 80 | TestBed.configureTestingModule({ |
Mohamed Asgar Samiulla(ma926a) | 8ac6f16 | 2018-03-08 14:54:47 +0530 | [diff] [blame] | 81 | declarations: [BuildDesignComponent, HomeComponent, TestComponent, HelpComponent, AboutUsComponent, LogoutComponent], |
| 82 | schemas: [NO_ERRORS_SCHEMA], |
| 83 | imports: [HttpModule, FormsModule, RouterTestingModule.withRoutes(routes)], |
IBM602-PC0F1E3C\Arundathi | cf1c531 | 2018-07-16 15:30:37 +0530 | [diff] [blame] | 84 | providers : [ NotificationsService ] |
Mohamed Asgar Samiulla(ma926a) | 8ac6f16 | 2018-03-08 14:54:47 +0530 | [diff] [blame] | 85 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 86 | }) |
| 87 | .compileComponents(); |
| 88 | })); |
| 89 | |
| 90 | beforeEach(() => { |
| 91 | fixture = TestBed.createComponent(BuildDesignComponent); |
| 92 | component = fixture.componentInstance; |
| 93 | fixture.detectChanges(); |
| 94 | }); |
| 95 | |
| 96 | it('should create', () => { |
| 97 | expect(component).toBeTruthy(); |
| 98 | }); |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 99 | |
| 100 | it('Should validate getRefData method', () => { |
IBM602-PC0F1E3C\Arundathi | cf1c531 | 2018-07-16 15:30:37 +0530 | [diff] [blame] | 101 | let refData = {"action":"Configure", |
| 102 | "action-level":"vnf", |
| 103 | "scope": { |
| 104 | "vnf-type":"ticktack", |
| 105 | "vnfc-type":"" |
| 106 | }, |
| 107 | "template":"Y", |
| 108 | "vm":[], |
| 109 | "device-protocol":"CHEF", |
| 110 | "user-name":"", |
| 111 | "port-number":"", |
| 112 | "artifact-list":[ |
| 113 | {"artifact-name":"template_Configure_ticktack_0.0.1V.json","artifact-type":"config_template"}, |
| 114 | {"artifact-name":"pd_Configure_ticktack_0.0.1V.yaml","artifact-type":"parameter_definitions"}], |
| 115 | "scopeType":"vnf-type" |
| 116 | }; |
| 117 | |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 118 | component.refDataRequiredFiels = false; |
| 119 | component.getRefData(refData); |
| 120 | expect(component.refDataRequiredFiels).toBeTruthy(); |
| 121 | }); |
| 122 | |
Mohamed Asgar Samiulla(ma926a) | 7f0939f | 2018-04-17 15:14:28 +0530 | [diff] [blame] | 123 | // Test checkRefDataReqFields Method |
| 124 | it('Should notify error message if action is not valid', () => { |
| 125 | let spy = spyOn(NotificationsService.prototype, 'error'); |
| 126 | component.refList = {"action": "", "scope": {"vnf-type": "test 1"}, "device-protocol": "ANSIBLE"}; |
| 127 | |
| 128 | component.checkRefDataReqFields(); |
| 129 | |
| 130 | expect(spy).toHaveBeenCalled(); |
| 131 | }); |
| 132 | |
| 133 | it('Should notify error message if VNF Type is not valid', () => { |
| 134 | let spy = spyOn(NotificationsService.prototype, 'error'); |
| 135 | component.refList = {"action": "Configure", "scope": {"vnf-type": ""}, "device-protocol": "ANSIBLE"}; |
| 136 | |
| 137 | component.checkRefDataReqFields(); |
| 138 | |
| 139 | expect(spy).toHaveBeenCalled(); |
| 140 | }); |
| 141 | |
| 142 | it('Should notify error message if Device Protocol is not valid', () => { |
| 143 | let spy = spyOn(NotificationsService.prototype, 'error'); |
| 144 | component.refList = {"action": "Configure", "scope": {"vnf-type": "test 1"}, "device-protocol": ""}; |
| 145 | |
| 146 | component.checkRefDataReqFields(); |
| 147 | |
| 148 | expect(spy).toHaveBeenCalled(); |
| 149 | }); |
Arundathi Patil | 50883a6 | 2018-07-31 14:38:10 +0530 | [diff] [blame] | 150 | |
| 151 | it('Should test updateAccessUpdatePages method to call setAllowOtherUpdates with true', ()=> { |
| 152 | spyOn(component, 'setAllowOtherUpdates'); |
| 153 | component.updateAccessUpdatePages('config', [{'action' : 'configModify'}, {'action' : 'config'}]); |
| 154 | expect(component.setAllowOtherUpdates).toHaveBeenCalledWith(true); |
| 155 | }); |
| 156 | |
| 157 | it('Should test updateAccessUpdatePages method to call setAllowOtherUpdates with fasle', ()=> { |
| 158 | spyOn(component, 'setAllowOtherUpdates'); |
| 159 | component.updateAccessUpdatePages('config', [{'action' : 'configModify'}]); |
| 160 | expect(component.setAllowOtherUpdates).toHaveBeenCalledWith(false); |
| 161 | }); |
Arundathi Patil | 7509cd4 | 2018-08-07 15:24:52 +0530 | [diff] [blame] | 162 | |
| 163 | it('Should notify error message if no valid template identifier', () => { |
| 164 | let spy = spyOn(NotificationsService.prototype, 'error'); |
Arundathi Patil | f59bdd9 | 2018-08-31 21:32:39 +0530 | [diff] [blame^] | 165 | component.refList = {"action": "ConfigScaleOut", "scope": {"vnf-type": "test 1"}, "device-protocol": "ANSIBLE"}; |
Arundathi Patil | 7509cd4 | 2018-08-07 15:24:52 +0530 | [diff] [blame] | 166 | |
| 167 | component.checkRefDataReqFields(); |
| 168 | |
| 169 | expect(spy).toHaveBeenCalled(); |
| 170 | }); |
Arundathi Patil | f203cc4 | 2018-08-09 19:09:30 +0530 | [diff] [blame] | 171 | |
| 172 | it('Should notify error message if action, deviceprotocol and scope are blank ', () => { |
| 173 | let spy = spyOn(NotificationsService.prototype, 'error'); |
| 174 | component.refList = {"action": "", "scope": {"vnf-type": ""}, "device-protocol": ""}; |
| 175 | |
| 176 | component.checkRefDataReqFields(); |
| 177 | |
| 178 | expect(spy).toHaveBeenCalled(); |
| 179 | }); |
Arundathi Patil | f59bdd9 | 2018-08-31 21:32:39 +0530 | [diff] [blame^] | 180 | |
| 181 | it('Should test setAllowOtherUpdates method', ()=> { |
| 182 | component.setAllowOtherUpdates(true); |
| 183 | }); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 184 | }); |