import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { BsModalService } from 'ngx-bootstrap/modal';
-import { TabsModule } from 'ngx-bootstrap/tabs';
+import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
-import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
-import { SharedModule } from '../../../shared/shared.module';
+import { SharedModule } from '~/app/shared/shared.module';
+import { configureTestBed, TabHelper } from '~/testing/unit-test-helper';
import { RgwUserS3Key } from '../models/rgw-user-s3-key';
import { RgwUserDetailsComponent } from './rgw-user-details.component';
configureTestBed({
declarations: [RgwUserDetailsComponent],
- imports: [BrowserAnimationsModule, HttpClientTestingModule, SharedModule, TabsModule.forRoot()],
- providers: [BsModalService, i18nProviders]
+ imports: [BrowserAnimationsModule, HttpClientTestingModule, SharedModule, NgbNavModule]
});
beforeEach(() => {
it('should create', () => {
expect(component).toBeTruthy();
- const detailsTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Details"]');
- expect(detailsTab).toBeTruthy();
- const keysTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Keys"]');
- expect(keysTab).toBeFalsy();
+ const tabs = TabHelper.getTextContents(fixture);
+ expect(tabs).toContain('Details');
+ expect(tabs).not.toContain('Keys');
});
it('should show "Details" tab', () => {
component.selection = { uid: 'myUsername' };
fixture.detectChanges();
- const detailsTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Details"]');
- expect(detailsTab).toBeTruthy();
- const keysTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Keys"]');
- expect(keysTab).toBeFalsy();
+ const tabs = TabHelper.getTextContents(fixture);
+ expect(tabs).toContain('Details');
+ expect(tabs).not.toContain('Keys');
});
it('should show "Keys" tab', () => {
component.ngOnChanges();
fixture.detectChanges();
- const detailsTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Details"]');
- expect(detailsTab).toBeTruthy();
- const keysTab = fixture.debugElement.nativeElement.querySelector('tab[heading="Keys"]');
- expect(keysTab).toBeTruthy();
+ const tabs = TabHelper.getTextContents(fixture);
+ expect(tabs).toContain('Details');
+ expect(tabs).toContain('Keys');
});
it('should show correct "System" info', () => {
const detailsTab = fixture.debugElement.nativeElement.querySelectorAll(
'.table.table-striped.table-bordered tr td'
);
- expect(detailsTab[6].textContent).toEqual('System');
- expect(detailsTab[7].textContent).toEqual('Yes');
+ expect(detailsTab[10].textContent).toEqual('System');
+ expect(detailsTab[11].textContent).toEqual('Yes');
component.selection.system = 'false';
component.ngOnChanges();
fixture.detectChanges();
- expect(detailsTab[7].textContent).toEqual('No');
+ expect(detailsTab[11].textContent).toEqual('No');
});
});