*
* ============LICENSE_END============================================
*
- *
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
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';
import 'rxjs/add/operator/catch';
let component: NewMenuComponent;
let fixture: ComponentFixture<NewMenuComponent>;
let adminService:AdminService;
- // let entryComponents:any;
beforeEach(async(() => {
TestBed.configureTestingModule({
let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of('your object'));
component.getFunctionCDselectData();
expect(spy).toHaveBeenCalled();
+ expect(component.result).toEqual('your object');
+ expect(component.functionCDselectData).toEqual('your object');
})
describe('should test getFunctionCDselectData method2',()=>{
let spy= spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.throw({status:404}))
component.getFunctionCDselectData();
expect(spy).toHaveBeenCalled();
+ expect(component.showSpinner).toEqual(false);
})
})
}else{
this.menu.menuSetCode='APP';
}
- //console.log("selected menu >>>>",this.menu);
this.getFunctionCDselectData();
this.getParentData();
}
this.showSpinner = true;
this.adminService.getParentData()
.subscribe( _data => {
- //console.log("getParentData :: _data ",_data);
this.result = _data;
if(_data){
this.parentListSelectData= _data; // data from server
}
heirarchicalMenuItems.sort(this.sortItems("label"));
this.childListSelectData = heirarchicalMenuItems;
- //console.log("childListSelectData ::: ",this.childListSelectData);
- //console.log("heirarchicalMenuItems ::: ",heirarchicalMenuItems);
- //console.log("parentListSelectData ::: ",this.parentListSelectData);
}
}, error => {
this.showSpinner = false;
updateFnMenu(){
this.showSpinner = true;
- //console.log("updateFnMenu Changes Called..",this.menu);
if( this.menu && this.menu.imageSrc == "" ) this.menu.imageSrc = "N/A";
if( this.menu && this.menu.target == "" ) this.menu.target = "N/A";
if( this.menu && this.menu.externalUrl == "" ) this.menu.externalUrl = "N/A";
this.menu.parentId=parseFloat(this.menu.parentId);
let data ={availableFnMenuItem: this.menu};
let postData = JSON.stringify(data);
- //console.log("postData >>>>>>",postData);
this.adminService.updateFnMenuItem(postData)
.subscribe( _data => {
this.result = _data;
}
getLeftMenuItems(){
- //console.log("getLeftMenuItems called after update menu");
let sidebarComponent = new SidebarComponent(this.router, this.sidebarService,this.cookieService);
sidebarComponent.ngOnInit();
}