grafana/public/app/features/dashboard/state/utils.test.ts
Hugo Häggmark d8e97fc024
Dashboard: Fixes rendering of repeating panels (#39991)
* Dashboard: Fixes rendering of repeating panels

* Chore: update after PR comments
2021-10-11 06:33:04 +02:00

36 lines
1.4 KiB
TypeScript

import { PanelModel } from './PanelModel';
import { isOnTheSameGridRow } from './utils';
import { REPEAT_DIR_HORIZONTAL } from '../../../core/constants';
describe('isOnTheSameGridRow', () => {
describe('when source panel is next to a panel', () => {
it('then it should return true', () => {
const sourcePanel: PanelModel = ({ gridPos: { x: 0, y: 1, w: 4, h: 4 } } as unknown) as PanelModel;
const otherPanel: PanelModel = ({ gridPos: { x: 4, y: 1, w: 4, h: 4 } } as unknown) as PanelModel;
expect(isOnTheSameGridRow(sourcePanel, otherPanel)).toBe(true);
});
});
describe('when source panel is not next to a panel', () => {
it('then it should return false', () => {
const sourcePanel: PanelModel = ({ gridPos: { x: 0, y: 1, w: 4, h: 4 } } as unknown) as PanelModel;
const otherPanel: PanelModel = ({ gridPos: { x: 4, y: 5, w: 4, h: 4 } } as unknown) as PanelModel;
expect(isOnTheSameGridRow(sourcePanel, otherPanel)).toBe(false);
});
});
describe('when source panel is repeated horizontally', () => {
it('then it should return false', () => {
const sourcePanel: PanelModel = ({
gridPos: { x: 0, y: 1, w: 4, h: 4 },
repeatDirection: REPEAT_DIR_HORIZONTAL,
} as unknown) as PanelModel;
const otherPanel: PanelModel = ({ gridPos: { x: 4, y: 1, w: 4, h: 4 } } as unknown) as PanelModel;
expect(isOnTheSameGridRow(sourcePanel, otherPanel)).toBe(false);
});
});
});