2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * * Modification Copyright © 2020 IBM.
9 * ===================================================================
11 * Unless otherwise specified, all software contained herein is licensed
12 * under the Apache License, Version 2.0 (the "License");
13 * you may not use this software except in compliance with the License.
14 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 * Unless otherwise specified, all documentation contained herein is licensed
25 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
26 * you may not use this documentation except in compliance with the License.
27 * You may obtain a copy of the License at
29 * https://creativecommons.org/licenses/by/4.0/
31 * Unless required by applicable law or agreed to in writing, documentation
32 * distributed under the License is distributed on an "AS IS" BASIS,
33 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 * See the License for the specific language governing permissions and
35 * limitations under the License.
37 * ============LICENSE_END============================================
42 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
43 import {FormsModule} from '@angular/forms';
44 import { NewMenuComponent } from './new-menu.component';
45 import { HttpClientTestingModule } from '@angular/common/http/testing';
46 import { NgbActiveModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
47 import { RouterTestingModule } from '@angular/router/testing';
48 import { CookieService } from 'ngx-cookie-service';
49 import { AdminService } from '../../admin.service';
50 import 'rxjs/add/operator/toPromise';
51 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
52 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
53 import 'rxjs/add/observable/of';
54 import { Observable } from 'rxjs/Observable';
55 import 'rxjs/add/operator/catch';
56 import 'rxjs/add/observable/throw';
57 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
60 describe('NewMenuComponent', () => {
61 let component: NewMenuComponent;
62 let fixture: ComponentFixture<NewMenuComponent>;
63 let adminService:AdminService;
65 beforeEach(async(() => {
66 TestBed.configureTestingModule({
67 declarations: [ NewMenuComponent,ConfirmationModalComponent ],
70 HttpClientTestingModule,
73 BrowserAnimationsModule
81 TestBed.overrideModule(BrowserDynamicTestingModule,{
83 entryComponents:[ConfirmationModalComponent ]
91 fixture = TestBed.createComponent(NewMenuComponent);
92 component = fixture.componentInstance;
93 fixture.detectChanges();
94 adminService=TestBed.get(AdminService);
97 it('should create', () => {
98 expect(component).toBeTruthy();
101 it('testing ngOnInit method for if condition',()=>{
102 component.selectedMenu=1;
103 component.ngOnInit();
104 expect(component.menu).toEqual(component.selectedMenu);
107 it('testing ngOnInit method for else condition',()=>{
108 component.selectedMenu=0;
109 component.ngOnInit();
110 expect(component.menu.menuSetCode).toEqual('APP');
113 it('testing sortItems method',()=>{
115 component.sortItems(prop);
119 it('testing getParentLabel method',()=>{
120 component.getParentLabel(1,"data");
124 it('should test getParentData method1 ',()=>{
125 const children="children";
126 let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'));
127 component.getParentData();
128 expect(spy).toHaveBeenCalled();
131 describe('should test getLeftMenuItems',()=>{
132 it('testing getLeftMenuItems',()=>{
133 component.getLeftMenuItems();
137 it('testing getFunctionCDselectData method1',()=>{
138 let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of('your object'));
139 component.getFunctionCDselectData();
140 expect(spy).toHaveBeenCalled();
143 it('should test updateFnMenu method',()=>{
144 component.menu.label!=null;
145 component.updateFnMenu();