tests: added test for DashboardRow

This commit is contained in:
Torkel Ödegaard 2017-10-24 15:46:03 +02:00
parent 15024e96e4
commit df12cbc4a7
3 changed files with 40 additions and 9 deletions

View File

@ -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});

View File

@ -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);
});
});

View File

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