summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-04-01 21:08:00 +0530
committerIndrijeet kumar <indriku1@in.ibm.com>2020-04-01 21:08:06 +0530
commit62546ca8cd1eeee7ec441bf5463a04a29a384836 (patch)
tree3833f551421c3776bffc49c9b82c30bc79ed559c /ecomp-sdk
parent7d3ad2425c0a774179ddb522e741d977c3bcf992 (diff)
test cases written in cache-admin comp
test cases written in cache-admin component Issue-ID: PORTAL-813 Change-Id: I99f4f737cd429554d02bf86be74e00ab5845ac2d Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts55
1 files changed, 51 insertions, 4 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
index 7a4bcec0..03d21797 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/cache-admin/cache-admin.component.spec.ts
@@ -2,27 +2,74 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CacheAdminComponent } from './cache-admin.component';
import { MatExpansionModule } from '@angular/material';
+import { HttpClientModule } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { AdminService } from '../admin.service';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/observable/of';
+import { CookieService } from 'ngx-cookie-service';
+import { SuccessModalComponent } from 'src/app/modals/success-modal/success-modal.component';
+import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+
+
describe('CacheAdminComponent', () => {
let component: CacheAdminComponent;
let fixture: ComponentFixture<CacheAdminComponent>;
+ let adminService:AdminService;
+
+ var stubData1={"data":'{"data":"cachedRegions"}'};
+ var stubData2={"data":"stubData2"};
beforeEach(async(() => {
+
TestBed.configureTestingModule({
- imports:[MatExpansionModule, HttpClientTestingModule],
- declarations: [ CacheAdminComponent ],
- schemas: [CUSTOM_ELEMENTS_SCHEMA]
+ declarations: [
+ CacheAdminComponent,
+ SuccessModalComponent,
+ ],
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ imports:[
+ MatExpansionModule,
+ HttpClientModule,
+ HttpClientTestingModule,
+ NgbModule.forRoot()
+ ],
+ providers:[CookieService,AdminService],
+ })
+ TestBed.overrideModule(BrowserDynamicTestingModule,{
+ set:{
+ entryComponents:[SuccessModalComponent]
+ }
})
.compileComponents();
- }));
+ }));
beforeEach(() => {
fixture = TestBed.createComponent(CacheAdminComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ adminService=TestBed.get(AdminService);
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+
+ describe('it should test ngOnInit method',()=>{
+ it('should test ngOnInit',()=>{
+ let spy=spyOn(adminService,'getCacheRegions').and.returnValue(Observable.of(stubData1));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+
+ it('it should test showRegionDetails method',()=>{
+ let spy=spyOn(adminService,'getCacheRegionDetails').and.returnValue(Observable.of(stubData2));
+ component.showRegionDetails("string");
+ expect(spy).toHaveBeenCalled();
+ })
+
});
+