]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
a70ccd0b802149cee74a0352fa8ccd80b64a23ec
[ceph-ci.git] /
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4 import { RouterTestingModule } from '@angular/router/testing';
5
6 import { NgBootstrapFormValidationModule } from 'ng-bootstrap-form-validation';
7 import { ToastrModule } from 'ngx-toastr';
8
9 import {
10   configureTestBed,
11   i18nProviders,
12   TabHelper
13 } from '../../../../../testing/unit-test-helper';
14 import { CoreModule } from '../../../../core/core.module';
15 import { Permissions } from '../../../../shared/models/permissions';
16 import { SharedModule } from '../../../../shared/shared.module';
17 import { CephModule } from '../../../ceph.module';
18 import { CephSharedModule } from '../../../shared/ceph-shared.module';
19 import { HostDetailsComponent } from './host-details.component';
20
21 describe('HostDetailsComponent', () => {
22   let component: HostDetailsComponent;
23   let fixture: ComponentFixture<HostDetailsComponent>;
24
25   configureTestBed({
26     imports: [
27       BrowserAnimationsModule,
28       HttpClientTestingModule,
29       NgBootstrapFormValidationModule.forRoot(),
30       RouterTestingModule,
31       CephModule,
32       CoreModule,
33       CephSharedModule,
34       SharedModule,
35       ToastrModule.forRoot()
36     ],
37     declarations: [],
38     providers: [i18nProviders]
39   });
40
41   beforeEach(() => {
42     fixture = TestBed.createComponent(HostDetailsComponent);
43     component = fixture.componentInstance;
44     component.selection = undefined;
45     component.permissions = new Permissions({
46       hosts: ['read'],
47       grafana: ['read']
48     });
49   });
50
51   it('should create', () => {
52     expect(component).toBeTruthy();
53   });
54
55   describe('Host details tabset', () => {
56     beforeEach(() => {
57       component.selection = { hostname: 'localhost' };
58       fixture.detectChanges();
59     });
60
61     it('should recognize a tabset child', () => {
62       const tabsetChild = TabHelper.getNgbNav(fixture);
63       expect(tabsetChild).toBeDefined();
64     });
65
66     it('should show tabs', () => {
67       expect(TabHelper.getTextContents(fixture)).toEqual([
68         'Devices',
69         'Inventory',
70         'Daemons',
71         'Performance Details',
72         'Device health'
73       ]);
74     });
75   });
76 });