1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3 import { CacheAdminComponent } from './cache-admin.component';
4 import { MatExpansionModule } from '@angular/material';
5 import { HttpClientModule } from '@angular/common/http';
6 import { HttpClientTestingModule } from '@angular/common/http/testing';
7 import { AdminService } from '../admin.service';
8 import { Observable } from 'rxjs/Observable';
9 import 'rxjs/add/observable/of';
10 import { CookieService } from 'ngx-cookie-service';
11 import { SuccessModalComponent } from 'src/app/modals/success-modal/success-modal.component';
12 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
13 import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
16 describe('CacheAdminComponent', () => {
17 let component: CacheAdminComponent;
18 let fixture: ComponentFixture<CacheAdminComponent>;
19 let adminService:AdminService;
21 var stubData1={"data":'{"data":"cachedRegions"}'};
22 var stubData2={"data":"stubData2"};
24 beforeEach(async(() => {
26 TestBed.configureTestingModule({
29 SuccessModalComponent,
31 schemas: [CUSTOM_ELEMENTS_SCHEMA],
35 HttpClientTestingModule,
38 providers:[CookieService,AdminService],
40 TestBed.overrideModule(BrowserDynamicTestingModule,{
42 entryComponents:[SuccessModalComponent]
49 fixture = TestBed.createComponent(CacheAdminComponent);
50 component = fixture.componentInstance;
51 fixture.detectChanges();
52 adminService=TestBed.get(AdminService);
55 it('should create', () => {
56 expect(component).toBeTruthy();
60 describe('it should test ngOnInit method',()=>{
61 it('should test ngOnInit',()=>{
62 let spy=spyOn(adminService,'getCacheRegions').and.returnValue(Observable.of(stubData1));
64 expect(spy).toHaveBeenCalled();
68 it('it should test showRegionDetails method',()=>{
69 let spy=spyOn(adminService,'getCacheRegionDetails').and.returnValue(Observable.of(stubData2));
70 component.showRegionDetails("string");
71 expect(spy).toHaveBeenCalled();