]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cephfs / cephfs-detail / cephfs-detail.component.spec.ts
index 256db87fa448d09fa954468d2cb2cdf51c366467..1d80097c92bbffa39bf46c4220625caf11499497 100644 (file)
@@ -1,11 +1,5 @@
-import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { Component, Input } from '@angular/core';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { RouterTestingModule } from '@angular/router/testing';
-
-import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
-import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
-import { TabsModule } from 'ngx-bootstrap/tabs';
 
 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
 import { SharedModule } from '../../../shared/shared.module';
@@ -17,36 +11,46 @@ class CephfsChartStubComponent {
   mdsCounter: any;
 }
 
-@Component({ selector: 'cd-cephfs-clients', template: '' })
-class CephfsClientsStubComponent {
-  @Input()
-  mdsCounter: any;
-}
-
 describe('CephfsDetailComponent', () => {
   let component: CephfsDetailComponent;
   let fixture: ComponentFixture<CephfsDetailComponent>;
 
+  const updateDetails = (
+    standbys: string,
+    pools: any[],
+    ranks: any[],
+    mdsCounters: object,
+    name: string
+  ) => {
+    component.data = {
+      standbys,
+      pools,
+      ranks,
+      mdsCounters,
+      name
+    };
+    fixture.detectChanges();
+  };
+
   configureTestBed({
-    imports: [
-      SharedModule,
-      RouterTestingModule,
-      BsDropdownModule.forRoot(),
-      ProgressbarModule.forRoot(),
-      TabsModule.forRoot(),
-      HttpClientTestingModule
-    ],
-    declarations: [CephfsDetailComponent, CephfsChartStubComponent, CephfsClientsStubComponent],
+    imports: [SharedModule],
+    declarations: [CephfsDetailComponent, CephfsChartStubComponent],
     providers: i18nProviders
   });
 
   beforeEach(() => {
     fixture = TestBed.createComponent(CephfsDetailComponent);
     component = fixture.componentInstance;
+    updateDetails('b', [], [], { a: { name: 'a', x: [0], y: [0, 1] } }, 'someFs');
     fixture.detectChanges();
+    component.ngOnChanges();
   });
 
   it('should create', () => {
     expect(component).toBeTruthy();
   });
+
+  it('prepares standby on change', () => {
+    expect(component.standbys).toEqual([{ key: 'Standby daemons', value: 'b' }]);
+  });
 });