1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { DebugElement } from '@angular/core';
3 import { ComponentFixture, TestBed } from '@angular/core/testing';
5 import { of } from 'rxjs';
7 import { TabsModule } from 'ngx-bootstrap/tabs';
9 import { configureTestBed, i18nProviders } from '../../../../../testing/unit-test-helper';
10 import { CoreModule } from '../../../../core/core.module';
11 import { OsdService } from '../../../../shared/api/osd.service';
12 import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
13 import { CephModule } from '../../../ceph.module';
14 import { PerformanceCounterModule } from '../../../performance-counter/performance-counter.module';
15 import { OsdDetailsComponent } from './osd-details.component';
17 describe('OsdDetailsComponent', () => {
18 let component: OsdDetailsComponent;
19 let fixture: ComponentFixture<OsdDetailsComponent>;
20 let debugElement: DebugElement;
21 let osdService: OsdService;
26 HttpClientTestingModule,
28 PerformanceCounterModule,
33 providers: i18nProviders
37 fixture = TestBed.createComponent(OsdDetailsComponent);
38 component = fixture.componentInstance;
40 component.selection = new CdTableSelection();
41 debugElement = fixture.debugElement;
42 osdService = debugElement.injector.get(OsdService);
44 getDetailsSpy = spyOn(osdService, 'getDetails');
46 fixture.detectChanges();
49 it('should create', () => {
50 expect(component).toBeTruthy();
53 it('should fail creating a histogram', () => {
54 const detailDataWithoutHistogram = {
59 getDetailsSpy.and.returnValue(of(detailDataWithoutHistogram));
60 component.osd = { tree: { id: 0 } };
62 expect(getDetailsSpy).toHaveBeenCalled();
63 expect(component.osd.histogram_failed).toBe('osd down');
66 it('should succeed creating a histogram', () => {
67 const detailDataWithHistogram = {
72 getDetailsSpy.and.returnValue(of(detailDataWithHistogram));
73 component.osd = { tree: { id: 0 } };
75 expect(getDetailsSpy).toHaveBeenCalled();
76 expect(component.osd.histogram_failed).toBe('');