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 { MockBackend } from '@angular/http/testing';
50 import { BaseRequestOptions, Http } from '@angular/http';
51 import { AdminService } from '../../admin.service';
52 import 'rxjs/add/operator/toPromise';
53 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
54 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
55 import { MaterialModule } from 'portalsdk-tag-lib/material-module';
56 import 'rxjs/add/observable/of';
57 import { Observable } from 'rxjs/Observable';
58 import 'rxjs/add/operator/catch';
59 import 'rxjs/add/observable/throw';
60 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
63 describe('NewMenuComponent', () => {
64 let component: NewMenuComponent;
65 let fixture: ComponentFixture<NewMenuComponent>;
66 let adminService:AdminService;
67 // let entryComponents:any;
69 beforeEach(async(() => {
70 TestBed.configureTestingModule({
71 declarations: [ NewMenuComponent,ConfirmationModalComponent ],
74 HttpClientTestingModule,
77 BrowserAnimationsModule
85 TestBed.overrideModule(BrowserDynamicTestingModule,{
87 entryComponents:[ConfirmationModalComponent ]
95 fixture = TestBed.createComponent(NewMenuComponent);
96 component = fixture.componentInstance;
97 fixture.detectChanges();
98 adminService=TestBed.get(AdminService);
101 it('should create', () => {
102 expect(component).toBeTruthy();
105 it('testing ngOnInit method for if condition',()=>{
106 component.selectedMenu=1;
107 component.ngOnInit();
108 expect(component.menu).toEqual(component.selectedMenu);
111 it('testing ngOnInit method for else condition',()=>{
112 component.selectedMenu=0;
113 component.ngOnInit();
114 expect(component.menu.menuSetCode).toEqual('APP');
117 it('testing sortItems method',()=>{
119 component.sortItems(prop);
123 it('testing getParentLabel method',()=>{
124 component.getParentLabel(1,"data");
128 it('should test getParentData method1 ',()=>{
129 const children="children";
130 let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'));
131 component.getParentData();
132 expect(spy).toHaveBeenCalled();
135 it('should test getParentData method2 error part ',()=>{
136 const children="children";
137 let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.throw({status:404}));
138 component.getParentData();
139 expect(spy).toHaveBeenCalled();
142 describe('should test getLeftMenuItems',()=>{
143 it('testing getLeftMenuItems',()=>{
144 component.getLeftMenuItems();
148 it('testing getFunctionCDselectData method1',()=>{
149 let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of('your object'));
150 component.getFunctionCDselectData();
151 expect(spy).toHaveBeenCalled();
154 describe('should test getFunctionCDselectData method2',()=>{
155 it('testing getFunctionCDselectData',()=>{
156 let spy= spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.throw({status:404}))
157 component.getFunctionCDselectData();
158 expect(spy).toHaveBeenCalled();
162 it('should test updateFnMenu method',()=>{
163 component.menu.label!=null;
164 component.updateFnMenu();