2022-08-08 10:43:35 -05:00
|
|
|
import { render } from '@testing-library/react';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-08-22 10:51:33 -05:00
|
|
|
import { DashboardMeta } from 'app/types';
|
|
|
|
|
2019-05-14 07:41:24 -05:00
|
|
|
import { DashboardModel } from '../state';
|
|
|
|
|
2022-04-22 08:33:13 -05:00
|
|
|
import { DashboardGridUnconnected as DashboardGrid, Props } from './DashboardGrid';
|
|
|
|
|
2021-12-13 06:42:33 -06:00
|
|
|
jest.mock('app/features/dashboard/dashgrid/LazyLoader', () => {
|
|
|
|
const LazyLoader: React.FC = ({ children }) => {
|
|
|
|
return <>{children}</>;
|
|
|
|
};
|
|
|
|
return { LazyLoader };
|
|
|
|
});
|
|
|
|
|
2022-08-22 10:51:33 -05:00
|
|
|
function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
|
2019-05-14 07:41:24 -05:00
|
|
|
const data = Object.assign(
|
|
|
|
{
|
|
|
|
title: 'My dashboard',
|
|
|
|
panels: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
type: 'graph',
|
|
|
|
title: 'My graph',
|
|
|
|
gridPos: { x: 0, y: 0, w: 24, h: 10 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
type: 'graph2',
|
|
|
|
title: 'My graph2',
|
|
|
|
gridPos: { x: 0, y: 10, w: 25, h: 10 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
type: 'graph3',
|
|
|
|
title: 'My graph3',
|
|
|
|
gridPos: { x: 0, y: 20, w: 25, h: 100 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
type: 'graph4',
|
|
|
|
title: 'My graph4',
|
|
|
|
gridPos: { x: 0, y: 120, w: 25, h: 10 },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
overrides
|
|
|
|
);
|
|
|
|
|
|
|
|
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides);
|
|
|
|
return new DashboardModel(data, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('DashboardGrid', () => {
|
2022-08-08 10:43:35 -05:00
|
|
|
it('should render without error', () => {
|
|
|
|
const props: Props = {
|
|
|
|
editPanel: null,
|
|
|
|
viewPanel: null,
|
|
|
|
dashboard: getTestDashboard(),
|
|
|
|
cleanAndRemoveMany: jest.fn,
|
|
|
|
};
|
|
|
|
expect(() => render(<DashboardGrid {...props} />)).not.toThrow();
|
2019-05-14 07:41:24 -05:00
|
|
|
});
|
|
|
|
});
|