Chore: Convert PanelHeaderCorner test to RTL (#51074)

* export props

* Convert PanelHeaderCorner test to RTL

* Update public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderCorner.test.tsx

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
Seyaji 2022-06-20 13:54:13 +01:00 committed by GitHub
parent ab89fa0853
commit 902101c524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View File

@ -113,9 +113,6 @@ exports[`no enzyme tests`] = {
"public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx:2723773538": [
[0, 35, 13, "RegExp match", "2409514259"]
],
"public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderCorner.test.tsx:2851646279": [
[0, 19, 13, "RegExp match", "2409514259"]
],
"public/app/features/datasources/DataSourceDashboards.test.tsx:1369048021": [
[0, 19, 13, "RegExp match", "2409514259"]
],

View File

@ -1,16 +1,26 @@
import { shallow } from 'enzyme';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { selectors } from '@grafana/e2e-selectors';
import { PanelModel } from '../../state';
import { PanelHeaderCorner } from './PanelHeaderCorner';
import PanelHeaderCorner, { Props } from './PanelHeaderCorner';
describe('Render', () => {
const setup = () => {
const testPanel = new PanelModel({ title: 'test', description: 'test panel' });
const props: Props = {
panel: testPanel,
};
return render(<PanelHeaderCorner {...props} />);
};
describe('Panel header corner test', () => {
it('should render component', () => {
const panel = new PanelModel({});
const wrapper = shallow(<PanelHeaderCorner panel={panel} />);
const instance = wrapper.instance() as PanelHeaderCorner;
setup();
expect(instance.getInfoContent()).toBeDefined();
expect(
screen.getByRole('region', { name: selectors.components.Panels.Panel.headerCornerInfo('info') })
).toBeInTheDocument();
});
});

View File

@ -14,7 +14,7 @@ enum InfoMode {
Links = 'Links',
}
interface Props {
export interface Props {
panel: PanelModel;
title?: string;
description?: string;