blob: 4635d1dc4789d61098f6fc9e2dc7cec18fa5888a [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
Arundathi Patil50883a62018-07-31 14:38:10 +05305
6Modification Copyright (C) 2018 IBM.
Skip Wonnell2c977e22018-03-01 08:30:15 -06007===================================================================
8
9Unless otherwise specified, all software contained herein is licensed
10under the Apache License, Version 2.0 (the License);
11you may not use this software except in compliance with the License.
12You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing, software
17distributed under the License is distributed on an "AS IS" BASIS,
18WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19See the License for the specific language governing permissions and
20limitations under the License.
21
Skip Wonnell2c977e22018-03-01 08:30:15 -060022============LICENSE_END============================================
23*/
24
25/* tslint:disable:no-unused-variable */
26import {async, ComponentFixture, TestBed} from '@angular/core/testing';
Mohamed Asgar Samiulla(ma926a)8ac6f162018-03-08 14:54:47 +053027import {NO_ERRORS_SCHEMA} from '@angular/core';
28import {FormsModule} from '@angular/forms';
29import {NotificationService} from '../../shared/services/notification.service';
30import {ParamShareService} from '../../shared/services/paramShare.service';
31import {MappingEditorService} from '../../shared/services/mapping-editor.service';
32import {ModalComponent} from '../../shared/modal/modal.component';
33import {DialogService} from 'ng2-bootstrap-modal';
34import {ConfirmComponent} from '../../shared/confirmModal/confirm.component';
35import {RouterTestingModule} from '@angular/router/testing';
36import {HttpUtilService} from '../../shared/services/httpUtil/http-util.service';
37import {UtilityService} from '../../shared/services/utilityService/utility.service';
38
39import {NotificationsService} from 'angular2-notifications';
40import {HomeComponent} from '../../home/home/home.component';
41import {LogoutComponent} from '../../shared/components/logout/logout.component';
42import {HelpComponent} from '../../shared/components/help/help/help.component';
43import {AboutUsComponent} from '../../about-us/aboutus.component';
44import {TestComponent} from '../../test/test.component';
45import {HttpModule} from '@angular/http';
46import { NgProgress } from 'ngx-progressbar';
Skip Wonnell2c977e22018-03-01 08:30:15 -060047
48import {BuildDesignComponent} from './build-artifacts.component';
49
50describe('BuildDesignComponent', () => {
51 let component: BuildDesignComponent;
52 let fixture: ComponentFixture<BuildDesignComponent>;
Mohamed Asgar Samiulla(ma926a)8ac6f162018-03-08 14:54:47 +053053 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 Wonnell2c977e22018-03-01 08:30:15 -060079 beforeEach(async(() => {
80 TestBed.configureTestingModule({
Mohamed Asgar Samiulla(ma926a)8ac6f162018-03-08 14:54:47 +053081 declarations: [BuildDesignComponent, HomeComponent, TestComponent, HelpComponent, AboutUsComponent, LogoutComponent],
82 schemas: [NO_ERRORS_SCHEMA],
83 imports: [HttpModule, FormsModule, RouterTestingModule.withRoutes(routes)],
IBM602-PC0F1E3C\Arundathicf1c5312018-07-16 15:30:37 +053084 providers : [ NotificationsService ]
Mohamed Asgar Samiulla(ma926a)8ac6f162018-03-08 14:54:47 +053085
Skip Wonnell2c977e22018-03-01 08:30:15 -060086 })
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 });
sj108sf27d5542018-04-02 14:46:25 +053099
100 it('Should validate getRefData method', () => {
IBM602-PC0F1E3C\Arundathicf1c5312018-07-16 15:30:37 +0530101 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
sj108sf27d5542018-04-02 14:46:25 +0530118 component.refDataRequiredFiels = false;
119 component.getRefData(refData);
120 expect(component.refDataRequiredFiels).toBeTruthy();
121 });
122
Mohamed Asgar Samiulla(ma926a)7f0939f2018-04-17 15:14:28 +0530123// 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 Patil50883a62018-07-31 14:38:10 +0530150
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 Patil7509cd42018-08-07 15:24:52 +0530162
163 it('Should notify error message if no valid template identifier', () => {
164 let spy = spyOn(NotificationsService.prototype, 'error');
Arundathi Patilf59bdd92018-08-31 21:32:39 +0530165 component.refList = {"action": "ConfigScaleOut", "scope": {"vnf-type": "test 1"}, "device-protocol": "ANSIBLE"};
Arundathi Patil7509cd42018-08-07 15:24:52 +0530166
167 component.checkRefDataReqFields();
168
169 expect(spy).toHaveBeenCalled();
170 });
Arundathi Patilf203cc42018-08-09 19:09:30 +0530171
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 Patilf59bdd92018-08-31 21:32:39 +0530180
181 it('Should test setAllowOtherUpdates method', ()=> {
182 component.setAllowOtherUpdates(true);
183 });
Skip Wonnell2c977e22018-03-01 08:30:15 -0600184});