]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add missing unit tests for CephFS chart
authorStephan Müller <smueller@suse.com>
Thu, 8 Aug 2019 14:33:35 +0000 (16:33 +0200)
committerStephan Müller <smueller@suse.com>
Fri, 23 Aug 2019 08:41:44 +0000 (10:41 +0200)
Fixes: https://tracker.ceph.com/issues/41166
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.spec.ts

index 54d7838f76662bbb4ada8907e31639168686ae9a..062ea869c4812bbc474a0cd792bf518d267e114b 100644 (file)
@@ -9,6 +9,8 @@ describe('CephfsChartComponent', () => {
   let component: CephfsChartComponent;
   let fixture: ComponentFixture<CephfsChartComponent>;
 
+  const counter = [[0, 15], [5, 15], [10, 25], [15, 50]];
+
   configureTestBed({
     imports: [ChartsModule],
     declarations: [CephfsChartComponent]
@@ -17,10 +19,55 @@ describe('CephfsChartComponent', () => {
   beforeEach(() => {
     fixture = TestBed.createComponent(CephfsChartComponent);
     component = fixture.componentInstance;
+    component.mdsCounter = {
+      'mds_server.handle_client_request': counter,
+      'mds_mem.ino': counter,
+      name: 'a'
+    };
     fixture.detectChanges();
   });
 
   it('should create', () => {
     expect(component).toBeTruthy();
   });
+
+  it('completed the chart', () => {
+    const lhs = component.chart.datasets[0].data;
+    expect(lhs.length).toBe(4);
+    expect(lhs).toEqual([
+      {
+        x: 0,
+        y: 15
+      },
+      {
+        x: 5000,
+        y: 15
+      },
+      {
+        x: 10000,
+        y: 25
+      },
+      {
+        x: 15000,
+        y: 50
+      }
+    ]);
+
+    const rhs = component.chart.datasets[1].data;
+    expect(rhs.length).toBe(3);
+    expect(rhs).toEqual([
+      {
+        x: 5000,
+        y: 0
+      },
+      {
+        x: 10000,
+        y: 2
+      },
+      {
+        x: 15000,
+        y: 5
+      }
+    ]);
+  });
 });