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