grafana_bak/public/app/features/dashboard-scene/utils/PanelModelCompatibilityWrapper.test.ts
2025-04-01 10:38:02 +09:00

30 lines
926 B
TypeScript

import { VizPanel } from '@grafana/scenes';
import { LibraryPanelBehavior } from '../scene/LibraryPanelBehavior';
import { PanelModelCompatibilityWrapper } from './PanelModelCompatibilityWrapper';
describe('PanelModelCompatibilityWrapper', () => {
it('Can get legacy id', () => {
const vizPanel = new VizPanel({ pluginId: 'test', title: 'test', description: 'test', key: 'panel-24' });
const panelModel = new PanelModelCompatibilityWrapper(vizPanel);
expect(panelModel.id).toBe(24);
});
it('Can get legacy id for lib panel', () => {
const panel = new VizPanel({ pluginId: 'test', title: 'test', description: 'test', key: 'panel-24' });
const libPanel = new LibraryPanelBehavior({
uid: 'a',
name: 'aa',
});
panel.setState({
$behaviors: [libPanel],
});
const panelModel = new PanelModelCompatibilityWrapper(panel);
expect(panelModel.id).toBe(24);
});
});