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';
6 import { TabsetComponent, TabsModule } from 'ngx-bootstrap/tabs';
8 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
9 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
10 import { Permissions } from '../../../shared/models/permissions';
11 import { SharedModule } from '../../../shared/shared.module';
12 import { RbdConfigurationListComponent } from '../../block/rbd-configuration-list/rbd-configuration-list.component';
13 import { PoolDetailsComponent } from './pool-details.component';
15 describe('PoolDetailsComponent', () => {
16 let poolDetailsComponent: PoolDetailsComponent;
17 let fixture: ComponentFixture<PoolDetailsComponent>;
21 BrowserAnimationsModule,
24 HttpClientTestingModule,
27 declarations: [PoolDetailsComponent, RbdConfigurationListComponent],
28 providers: [i18nProviders]
32 fixture = TestBed.createComponent(PoolDetailsComponent);
33 poolDetailsComponent = fixture.componentInstance;
34 poolDetailsComponent.selection = new CdTableSelection();
35 poolDetailsComponent.permissions = new Permissions({
38 fixture.detectChanges();
41 it('should create', () => {
42 expect(poolDetailsComponent).toBeTruthy();
45 describe('Pool details tabset', () => {
47 poolDetailsComponent.selection.selected = [
55 it('should recognize a tabset child', () => {
56 fixture.detectChanges();
57 const tabsetChild: TabsetComponent = poolDetailsComponent.tabsetChild;
58 expect(tabsetChild).toBeDefined();
61 it('should show "Cache Tiers Details" tab if selected pool has "tiers"', () => {
62 fixture.detectChanges();
63 const tabs = poolDetailsComponent.tabsetChild.tabs;
64 expect(tabs.length).toBe(3);
65 expect(tabs[2].heading).toBe('Cache Tiers Details');
66 expect(tabs[0].active).toBeTruthy();
69 it('should not show "Cache Tiers Details" tab if selected pool has no "tiers"', () => {
70 poolDetailsComponent.selection.selected = [
75 fixture.detectChanges();
76 const tabs = poolDetailsComponent.tabsetChild.tabs;
77 expect(tabs.length).toEqual(2);
78 expect(tabs[0].active).toBeTruthy();
81 it('current active status of tabs should not change when selection is the same as previous selection', () => {
82 fixture.detectChanges();
83 const tabs = poolDetailsComponent.tabsetChild.tabs;
84 expect(tabs[0].active).toBeTruthy();
86 tabs[1].active = true;
87 fixture.detectChanges();
88 expect(tabs[1].active).toBeTruthy();
91 it('returns pool details correctly', () => {
92 const pool = { prop1: 1, cdIsBinary: true, prop2: 2, cdExecuting: true, prop3: 3 };
93 const expectedPool = { prop1: 1, prop2: 2, prop3: 3 };
95 expect(poolDetailsComponent.filterNonPoolData(pool)).toEqual(expectedPool);
98 it('pool data filtering is called', () => {
99 const filterNonPoolDataSpy = spyOn(
100 poolDetailsComponent,
104 fixture.detectChanges();
106 expect(filterNonPoolDataSpy).toHaveBeenCalled();