summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src
diff options
context:
space:
mode:
authorLorraine Welch <lb2391@att.com>2020-03-05 17:19:20 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-05 17:19:20 +0000
commit81a75a99176990742e85d6169d966fe93d0a1c4a (patch)
treef629a1f481546a125dcc3c25b10bdde589338b94 /ecomp-sdk/epsdk-app-overlay/src
parentf429b28cc7f5a26a8c6ebff43139841f2499018e (diff)
parent76090facac52a009f2d44c261075cbe3529b4150 (diff)
Merge "test cases written for new-menu component"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts83
1 files changed, 77 insertions, 6 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
index 97ddeaaa..dc0301a4 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts
@@ -4,7 +4,10 @@
* ===================================================================
* Copyright © 2019 AT&T Intellectual Property. All rights reserved.
* ===================================================================
- *
+ *
+ * * Modification Copyright © 2020 IBM.
+ * ===================================================================
+
* Unless otherwise specified, all software contained herein is licensed
* under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
@@ -40,33 +43,101 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {FormsModule} from '@angular/forms';
import { NewMenuComponent } from './new-menu.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
-import { RouterModule } from '@angular/router';
+import { NgbActiveModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { RouterTestingModule } from '@angular/router/testing';
import { CookieService } from 'ngx-cookie-service';
-
+import { MockBackend } from '@angular/http/testing';
+import { BaseRequestOptions, Http } from '@angular/http';
+import { AdminService } from '../../admin.service';
+import 'rxjs/add/operator/toPromise';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { MaterialModule } from 'portalsdk-tag-lib/material-module';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
describe('NewMenuComponent', () => {
let component: NewMenuComponent;
let fixture: ComponentFixture<NewMenuComponent>;
+ let adminService:AdminService;
+ // let entryComponents:any;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NewMenuComponent ],
- imports:[FormsModule, HttpClientTestingModule,RouterTestingModule],
- providers:[NgbActiveModal,CookieService]
+ imports:[FormsModule, HttpClientTestingModule,RouterTestingModule,NgbModalModule,BrowserAnimationsModule],
+ providers:[AdminService,NgbActiveModal,CookieService,MockBackend,BaseRequestOptions,{
+ provide:Http,
+ useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{
+ return new Http(backend,defaultOptions);
+ },
+ deps:[MockBackend,BaseRequestOptions],
+ entryComponents:[ConfirmationModalComponent]
+ }],
})
.compileComponents();
+
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ adminService=TestBed.get(AdminService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('testing ngOnInit method for if condition',()=>{
+ component.selectedMenu=1;
+ component.ngOnInit();
+ expect(component.menu).toEqual(component.selectedMenu);
+ })
+
+ it('testing ngOnInit method for else condition',()=>{
+ component.selectedMenu=0;
+ component.ngOnInit();
+ expect(component.menu.menuSetCode).toEqual('APP');
+ })
+
+ it('testing sortItems method',()=>{
+ let prop: any;
+ component.sortItems(prop);
+
+ })
+
+ it('testing getParentLabel method',()=>{
+ component.getParentLabel(1,"data");
+ })
+
+ describe('should test getParentData',()=>{
+ it('testing getParentData',()=>{
+ let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object'));
+ component.getParentData();
+ expect(spy).toHaveBeenCalled();
+
+ })
+ })
+
+ describe('should test getLeftMenuItems',()=>{
+ it('testing getLeftMenuItems',()=>{
+ component.getLeftMenuItems();
+ })
+ })
+
+ describe('should test getFunctionCDselectData',()=>{
+ it('testing getFunctionCDselectData',()=>{
+ let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of(1,1));
+ component.getFunctionCDselectData();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+
+ it('should test updateFnMenu method',()=>{
+ //component.updateFnMenu();
+ })
+
});