]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / rgw / rgw-user-details / rgw-user-details.component.spec.ts
index 1b29228c38cabc511e98c849b4816d134e654714..126fdf44ff26468b1a7a8d258ccdb63615b010a2 100644 (file)
@@ -2,11 +2,10 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
 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';
 
@@ -16,8 +15,7 @@ describe('RgwUserDetailsComponent', () => {
 
   configureTestBed({
     declarations: [RgwUserDetailsComponent],
-    imports: [BrowserAnimationsModule, HttpClientTestingModule, SharedModule, TabsModule.forRoot()],
-    providers: [BsModalService, i18nProviders]
+    imports: [BrowserAnimationsModule, HttpClientTestingModule, SharedModule, NgbNavModule]
   });
 
   beforeEach(() => {
@@ -30,20 +28,18 @@ describe('RgwUserDetailsComponent', () => {
   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', () => {
@@ -52,10 +48,9 @@ describe('RgwUserDetailsComponent', () => {
     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', () => {
@@ -67,13 +62,13 @@ describe('RgwUserDetailsComponent', () => {
     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');
   });
 });