Explorar o código

tests: added test for DashboardRow

Torkel Ödegaard %!s(int64=8) %!d(string=hai) anos
pai
achega
df12cbc4a7

+ 7 - 1
public/app/features/dashboard/dashgrid/DashboardRow.tsx

@@ -2,6 +2,7 @@ import React from 'react';
 import classNames from 'classnames';
 import {PanelModel} from '../panel_model';
 import {PanelContainer} from './PanelContainer';
+import appEvents from 'app/core/app_events';
 
 export interface DashboardRowProps {
   panel: PanelModel;
@@ -31,7 +32,12 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
     });
   }
 
-  openSettings() {}
+  openSettings() {
+    appEvents.emit('show-modal', {
+      src: 'public/app/features/dashboard/partials/shareModal.html',
+      scope: shareScope
+    });
+  }
 
   render() {
     const classes = classNames({'dashboard-row': true, 'dashboard-row--collapsed': this.state.collapsed});

+ 33 - 0
public/app/features/dashboard/specs/DashboardRow.jest.tsx

@@ -0,0 +1,33 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import { DashboardRow } from '../dashgrid/DashboardRow';
+import { PanelModel } from '../panel_model';
+
+describe('DashboardRow', () => {
+  let wrapper, panel, getPanelContainer, dashboardMock;
+
+  beforeEach(() => {
+    dashboardMock = {toggleRow: jest.fn()};
+
+    getPanelContainer = jest.fn().mockReturnValue({
+      getDashboard: jest.fn().mockReturnValue(dashboardMock),
+      getPanelLoader: jest.fn()
+    });
+
+    panel = new PanelModel({collapsed: false});
+    wrapper = shallow(<DashboardRow panel={panel} getPanelContainer={getPanelContainer} />);
+  });
+
+  it('Should not have collapsed class when collaped is false', () => {
+    expect(wrapper.find('.dashboard-row')).toHaveLength(1);
+    expect(wrapper.find('.dashboard-row--collapsed')).toHaveLength(0);
+  });
+
+  it('Should collapse after clicking title', () => {
+    wrapper.find('.dashboard-row__title').simulate('click');
+
+    expect(wrapper.find('.dashboard-row--collapsed')).toHaveLength(1);
+    expect(dashboardMock.toggleRow.mock.calls).toHaveLength(1);
+  });
+
+});

+ 0 - 8
public/sass/components/_row.scss

@@ -17,14 +17,6 @@
       opacity: 1;
     }
   }
-
-  &:hover {
-    .dashboard-row__actions {
-      visibility: visible;
-      opacity: 1;
-      transition: opacity 200ms ease-in-out 100ms;
-    }
-  }
 }
 
 .dashboard-row__title {