diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-03-05 22:09:10 +0530 |
---|---|---|
committer | Indrijeet kumar <indriku1@in.ibm.com> | 2020-03-05 22:09:18 +0530 |
commit | 76090facac52a009f2d44c261075cbe3529b4150 (patch) | |
tree | 9427a6f0732f91ce0a497da02ed76f94e440ae80 /ecomp-sdk/epsdk-app-overlay/src | |
parent | c609ff2416224308262435b5d551700ef5f264d0 (diff) |
test cases written for new-menu component
test cases written for new-menu component
Issue-ID: PORTAL-813
Change-Id: I94f38de37e3011ff6d93e3b47b8085e6adf93925
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
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.ts | 83 |
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(); + }) + }); |