From bc8c025e020b57c9b8add5889b0ed76ffc061a2b Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 10 May 2018 16:17:39 +0100 Subject: [PATCH] mgr/dashboard: Fix unit tests cli warnings Signed-off-by: Tiago Melo --- .../performance-counter.component.spec.ts | 29 +++++++------- ...able-performance-counter.component.spec.ts | 34 ++++++++++------ .../rgw-bucket-list.component.spec.ts | 39 +++++++++---------- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/performance-counter/performance-counter.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/performance-counter/performance-counter.component.spec.ts index d6ff1b54878..fee8d2cfa61 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/performance-counter/performance-counter.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/performance-counter/performance-counter.component.spec.ts @@ -1,14 +1,16 @@ +import { Component, Input } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { BsDropdownModule } from 'ngx-bootstrap'; - -import { - PerformanceCounterService -} from '../../../shared/api/performance-counter.service'; -import { PerformanceCounterModule } from '../performance-counter.module'; +import { PerformanceCounterService } from '../../../shared/api/performance-counter.service'; import { PerformanceCounterComponent } from './performance-counter.component'; +@Component({ selector: 'cd-table-performance-counter', template: '' }) +class TablePerformanceCounterStubComponent { + @Input() serviceType: string; + @Input() serviceId: string; +} + describe('PerformanceCounterComponent', () => { let component: PerformanceCounterComponent; let fixture: ComponentFixture; @@ -26,14 +28,13 @@ describe('PerformanceCounterComponent', () => { } }; - beforeEach( - async(() => { - TestBed.configureTestingModule({ - imports: [PerformanceCounterModule, BsDropdownModule.forRoot(), RouterTestingModule], - providers: [{ provide: PerformanceCounterService, useValue: fakeService }] - }).compileComponents(); - }) - ); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PerformanceCounterComponent, TablePerformanceCounterStubComponent], + imports: [RouterTestingModule], + providers: [{ provide: PerformanceCounterService, useValue: fakeService }] + }).compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(PerformanceCounterComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.spec.ts index 6a219590074..58d53ae4e1b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.spec.ts @@ -1,27 +1,37 @@ -import { HttpClientModule } from '@angular/common/http'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { Component, Input } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { BsDropdownModule } from 'ngx-bootstrap'; +import { Observable } from 'rxjs/Observable'; -import { SharedModule } from '../../../shared/shared.module'; +import { PerformanceCounterService } from '../../../shared/api/performance-counter.service'; +import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; +import { FormatterService } from '../../../shared/services/formatter.service'; import { TablePerformanceCounterComponent } from './table-performance-counter.component'; +@Component({ selector: 'cd-table', template: '' }) +class TableStubComponent { + @Input() data: any[]; + @Input() columns: CdTableColumn[]; + @Input() autoReload: any = 5000; +} + describe('TablePerformanceCounterComponent', () => { let component: TablePerformanceCounterComponent; let fixture: ComponentFixture; + const fakeService = {}; + beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ TablePerformanceCounterComponent ], - imports: [ - HttpClientTestingModule, - HttpClientModule, - BsDropdownModule.forRoot(), - SharedModule + declarations: [TablePerformanceCounterComponent, TableStubComponent, DimlessPipe], + imports: [], + providers: [ + { provide: PerformanceCounterService, useValue: fakeService }, + DimlessPipe, + FormatterService ] - }) - .compileComponents(); + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.spec.ts index 4df24b8d4b8..b06707ba311 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.spec.ts @@ -1,16 +1,26 @@ -import { HttpClientModule } from '@angular/common/http'; +import { Component, Input } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { BsDropdownModule } from 'ngx-bootstrap'; -import { TabsModule } from 'ngx-bootstrap/tabs'; +import { ModalModule } from 'ngx-bootstrap'; import { RgwBucketService } from '../../../shared/api/rgw-bucket.service'; -import { DataTableModule } from '../../../shared/datatable/datatable.module'; -import { SharedModule } from '../../../shared/shared.module'; -import { RgwBucketDetailsComponent } from '../rgw-bucket-details/rgw-bucket-details.component'; +import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { RgwBucketListComponent } from './rgw-bucket-list.component'; +@Component({ selector: 'cd-rgw-bucket-details', template: '' }) +class RgwBucketDetailsStubComponent { + @Input() selection: CdTableSelection; +} + +@Component({ selector: 'cd-table', template: '' }) +class TableStubComponent { + @Input() data: any[]; + @Input() columns: CdTableColumn[]; + @Input() autoReload: any = 5000; +} + describe('RgwBucketListComponent', () => { let component: RgwBucketListComponent; let fixture: ComponentFixture; @@ -25,21 +35,10 @@ describe('RgwBucketListComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ - RgwBucketListComponent, - RgwBucketDetailsComponent - ], - imports: [ - HttpClientModule, - RouterTestingModule, - BsDropdownModule.forRoot(), - TabsModule.forRoot(), - DataTableModule, - SharedModule - ], + declarations: [RgwBucketListComponent, RgwBucketDetailsStubComponent, TableStubComponent], + imports: [RouterTestingModule, ModalModule.forRoot()], providers: [{ provide: RgwBucketService, useValue: fakeRgwBucketService }] - }) - .compileComponents(); + }).compileComponents(); })); beforeEach(() => { -- 2.39.5