import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
import * as _ from 'lodash';
import { TabsModule } from 'ngx-bootstrap/tabs';
let component: NfsDetailsComponent;
let fixture: ComponentFixture<NfsDetailsComponent>;
+ const elem = (css) => fixture.debugElement.query(By.css(css));
+
configureTestBed({
declarations: [NfsDetailsComponent],
imports: [SharedModule, TabsModule.forRoot(), HttpClientTestingModule],
squash: 'no_root_squash',
protocols: [3, 4],
transports: ['TCP', 'UDP'],
- clients: [],
+ clients: [
+ {
+ addresses: ['192.168.0.10', '192.168.1.0/8'],
+ access_type: 'RW',
+ squash: 'root_id_squash'
+ }
+ ],
id: 'cluster1:1',
state: 'LOADING'
}
];
component.selection.update();
-
+ component.ngOnChanges();
fixture.detectChanges();
});
- beforeEach(() => {});
-
it('should create', () => {
- component.ngOnChanges();
expect(component.data).toBeTruthy();
});
it('should prepare data', () => {
- component.ngOnChanges();
expect(component.data).toEqual({
'Access Type': 'RW',
'CephFS Filesystem': 1,
Transport: ['TCP', 'UDP']
});
});
+
+ it('should have 1 client', () => {
+ expect(elem('li.nav-item:nth-of-type(2) span').nativeElement.textContent).toBe('Clients (1)');
+ expect(component.clients).toEqual([
+ {
+ access_type: 'RW',
+ addresses: ['192.168.0.10', '192.168.1.0/8'],
+ squash: 'root_id_squash'
+ }
+ ]);
+ });
});
import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';
+import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
@Component({
selectedItem: any;
data: any;
- constructor(private i18n: I18n) {}
+ clientsColumns: CdTableColumn[];
+ clients = [];
+
+ constructor(private i18n: I18n) {
+ this.clientsColumns = [
+ {
+ name: this.i18n('Addresses'),
+ prop: 'addresses',
+ flexGrow: 2
+ },
+ {
+ name: this.i18n('Access Type'),
+ prop: 'access_type',
+ flexGrow: 1
+ },
+ {
+ name: this.i18n('Squash'),
+ prop: 'squash',
+ flexGrow: 1
+ }
+ ];
+ }
ngOnChanges() {
if (this.selection.hasSelection) {
this.selectedItem = this.selection.first();
+
+ this.clients = this.selectedItem.clients;
+
this.data = {};
this.data[this.i18n('Cluster')] = this.selectedItem.cluster_id;
this.data[this.i18n('Daemons')] = this.selectedItem.daemons;