summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts60
1 files changed, 27 insertions, 33 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
index cc710b5c..7f5a43fe 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts
@@ -4,7 +4,7 @@
* ===================================================================
* Copyright © 2019 AT&T Intellectual Property. All rights reserved.
*
- * Modification Copyright © 2019 IBM.
+ * Modification Copyright © 2020 IBM.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -40,46 +40,37 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
+import { HttpClientModule } from '@angular/common/http';
import { SidebarComponent } from './sidebar.component';
import { LayoutModule } from '../../layout.module';
-import { Session } from 'protractor';
import { CookieService } from 'ngx-cookie-service';
import { SidebarService } from 'src/app/shared/services';
-import { ReplaySubject } from 'rxjs';
import 'rxjs/add/observable/of';
-import { Observable } from 'rxjs/Observable';
-import { BaseRequestOptions, Http, XHRBackend } from '@angular/http';
-import { MockBackend } from '@angular/http/testing';
-import { environment } from 'src/environments/environment';
-import { inject } from '@angular/core';
-import { Response } from '@angular/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { Observable } from 'rxjs';
describe('SidebarComponent', () => {
let component: SidebarComponent;
let fixture: ComponentFixture<SidebarComponent>;
let sidebarService: SidebarService;
- let spy:any;
-
- let mockSidebarService = {
- navigate: jasmine.createSpy('navigate')
- };
+
+ var stubData1={
+ "data":'{"data":"cachedRegions"}',
+ "data2":'{"data2":"cachedRegions2"}'
+ };
+
beforeEach(async(() => {
+ let sidebarService: SidebarService;
TestBed.configureTestingModule({
imports: [
LayoutModule,
RouterTestingModule,
TranslateModule.forRoot(),
+ HttpClientModule,
HttpClientTestingModule
],
- providers:[CookieService, SidebarService,MockBackend, BaseRequestOptions, {
- provide: Http,
- useFactory: (backend: XHRBackend, defaultOptions: BaseRequestOptions) => {
- return new Http(backend, defaultOptions);
- },
- deps: [MockBackend, BaseRequestOptions],
- }],
+ providers:[CookieService, SidebarService],
})
.compileComponents();
}));
@@ -89,22 +80,25 @@ describe('SidebarComponent', () => {
component = fixture.componentInstance;
fixture.detectChanges();
sidebarService = TestBed.get(SidebarService);
+
});
it('should create', () => {
expect(component).toBeTruthy();
});
+ it('testing if condition in ngOnInit method',()=>{
+ component.cookieService.set('show_app_header','false');
+ component.ngOnInit();
+ expect(component.showHeader).toBe(false)
+ })
+
+
describe('should test ngOnInit',()=>{
- it('should validate on ngOnInit',(done)=>{
- var result=sidebarService.getLeftMenu()
- spy=spyOn(sidebarService, 'getLeftMenu').and.returnValue(result);
- fixture.detectChanges();
- sidebarService.getLeftMenu();
- expect(spy).toHaveBeenCalled();
- component.ngOnInit();
- done()
- //expect(component.result).toEqual(result)
+ it('should validate on ngOnInit',()=>{
+ let spy=spyOn(sidebarService,'getLeftMenu').and.returnValue(Observable.of(stubData1));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
})
})
@@ -134,15 +128,15 @@ describe('SidebarComponent', () => {
it('should test isToggled method',()=>{
expect(component.isToggled()).toBe(false);
- });
+ })
it('should test toggleSidebar method',()=>{
component.pushRightClass="kumar";
expect(component.toggleSidebar()).toBeUndefined;
- });
+ })
it('should test on onLoggedout method',()=>{
expect(localStorage.getItem('isLoggedin')).toBeFalsy
- });
+ })
});