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