From df12cbc4a7fda998125345e9be257a70ad560229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 24 Oct 2017 15:46:03 +0200 Subject: [PATCH] tests: added test for DashboardRow --- .../dashboard/dashgrid/DashboardRow.tsx | 8 ++++- .../dashboard/specs/DashboardRow.jest.tsx | 33 +++++++++++++++++++ public/sass/components/_row.scss | 8 ----- 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 public/app/features/dashboard/specs/DashboardRow.jest.tsx diff --git a/public/app/features/dashboard/dashgrid/DashboardRow.tsx b/public/app/features/dashboard/dashgrid/DashboardRow.tsx index 023ff5ca014..6a425d9c176 100644 --- a/public/app/features/dashboard/dashgrid/DashboardRow.tsx +++ b/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 { }); } - 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}); diff --git a/public/app/features/dashboard/specs/DashboardRow.jest.tsx b/public/app/features/dashboard/specs/DashboardRow.jest.tsx new file mode 100644 index 00000000000..2d44f2e0e74 --- /dev/null +++ b/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(); + }); + + 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); + }); + +}); diff --git a/public/sass/components/_row.scss b/public/sass/components/_row.scss index bb62c36250a..85e5fa8f8f8 100644 --- a/public/sass/components/_row.scss +++ b/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 {