diff options
author | 2019-08-22 16:55:57 +0800 | |
---|---|---|
committer | 2019-08-22 16:56:09 +0800 | |
commit | d0f5347dc16b5aa9fc95eb520fbc9a1c7b672b09 (patch) | |
tree | b3891d8de290d755d7f0f00d35bb77d3b89ad747 /usecaseui-portal/src/app/alarm/alarm.component.spec.ts | |
parent | 56923755c761897cc86ca2457667fcc3e6a0e43f (diff) |
feat: change the project structure and add mock data function
Change-Id: I381845bff5eb37d1fab3eba8cf1ae7838df523b7
Issue-ID: USECASEUI-307
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/alarm/alarm.component.spec.ts')
-rw-r--r-- | usecaseui-portal/src/app/alarm/alarm.component.spec.ts | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/usecaseui-portal/src/app/alarm/alarm.component.spec.ts b/usecaseui-portal/src/app/alarm/alarm.component.spec.ts deleted file mode 100644 index f64bcb83..00000000 --- a/usecaseui-portal/src/app/alarm/alarm.component.spec.ts +++ /dev/null @@ -1,66 +0,0 @@ -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'; - -import { AlarmComponent } from './alarm.component'; -import { DetailsComponent } from '../components/details/details.component'; -import { LineComponent } from '../components/charts/line/line.component'; -import { HomesService } from '../homes.service'; - -fdescribe('AlarmComponent', () => { - let component: AlarmComponent; - let fixture: ComponentFixture<AlarmComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AlarmComponent, DetailsComponent, LineComponent ], - imports: [ TranslateModule.forRoot({loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }}), - NgZorroAntdModule.forRoot(), - NgxEchartsModule, - HttpClientModule, - BrowserAnimationsModule, - HttpClientTestingModule ], - providers: [ TranslateService, HomesService, - { provide: NZ_I18N, useValue: en_US } ], - schemas: [ - CUSTOM_ELEMENTS_SCHEMA, - NO_ERRORS_SCHEMA - ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AlarmComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - 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: ...}); - }) -); -}); |