diff options
author | Arundathi Patil <arundpil@in.ibm.com> | 2019-08-06 17:25:19 +0530 |
---|---|---|
committer | Arundathi Patil <arundpil@in.ibm.com> | 2019-08-06 17:25:29 +0530 |
commit | 9d6a02acad17dc6f8b7afe63aab20e55bb8eb395 (patch) | |
tree | a0f36f3f179bcfa4f5cab398888a8e1013536548 | |
parent | 8efaf0a28dc2b26be9871ccfd1a376e34b372bb6 (diff) |
alarm component spec changes
Fixed errors in alarm component spec file
Issue-ID: USECASEUI-280
Change-Id: Ic1cd9c5ad3c1c5ebf0758570abdcc1a84ad637d1
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
-rw-r--r-- | usecaseui-portal/src/app/alarm/alarm.component.spec.ts | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/usecaseui-portal/src/app/alarm/alarm.component.spec.ts b/usecaseui-portal/src/app/alarm/alarm.component.spec.ts index 2cf268dd..f64bcb83 100644 --- a/usecaseui-portal/src/app/alarm/alarm.component.spec.ts +++ b/usecaseui-portal/src/app/alarm/alarm.component.spec.ts @@ -1,9 +1,10 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed, inject, fakeAsync } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { NgxEchartsModule } from 'ngx-echarts'; import { NgZorroAntdModule } from 'ng-zorro-antd'; import { TranslateModule, TranslateLoader, TranslateService, TranslateFakeLoader} from '@ngx-translate/core'; import { HttpClientModule } from '@angular/common/http'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NZ_I18N, en_US } from 'ng-zorro-antd'; @@ -23,7 +24,8 @@ fdescribe('AlarmComponent', () => { NgZorroAntdModule.forRoot(), NgxEchartsModule, HttpClientModule, - BrowserAnimationsModule ], + BrowserAnimationsModule, + HttpClientTestingModule ], providers: [ TranslateService, HomesService, { provide: NZ_I18N, useValue: en_US } ], schemas: [ @@ -40,7 +42,25 @@ fdescribe('AlarmComponent', () => { fixture.detectChanges(); }); - it('should create', () => { + it('should create', inject([HttpTestingController, HomesService], + (httpMock: HttpTestingController, service: HomesService) => { expect(component).toBeTruthy(); - }); + })); + + it('expects service to fetch data with proper sorting', + inject([HttpTestingController, HomesService], + (httpMock: HttpTestingController, service: HomesService) => { + // We call the service + service.getqueryAllSourceNames().subscribe(data => { + expect(data.pageInfo.totalRecordCount).toBe(21); + expect(data.pageInfo.pageNumber).toBe(0); + expect(data.data.length).toBe(7); + }); + // We set the expectations for the HttpClient mock + const req = httpMock.expectOne('http://.../data/contacts'); + expect(req.request.method).toEqual('GET'); + // Then we set the fake data to be returned by the mock + req.flush({data: ...}); + }) +); }); |