mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tests: added test for DashboardRow
This commit is contained in:
parent
15024e96e4
commit
df12cbc4a7
@ -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
public/app/features/dashboard/specs/DashboardRow.jest.tsx
Normal file
33
public/app/features/dashboard/specs/DashboardRow.jest.tsx
Normal 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);
|
||||
});
|
||||
|
||||
});
|
@ -17,14 +17,6 @@
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.dashboard-row__actions {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition: opacity 200ms ease-in-out 100ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dashboard-row__title {
|
||||
|
Loading…
Reference in New Issue
Block a user