grafana/public/app/features/panel/state/utils.test.ts
Ashley Harrison f8d89eff56
Chore: fix type errors in tests (#63270)
* fix any's in tests

* fix more any's in tests

* more test type fixes

* fixing any's in tests part 3

* more test type fixes

* fixing test any's p5

* some tidy up

* fix template_srv
2023-02-14 16:46:42 +01:00

27 lines
1.1 KiB
TypeScript

import { PanelPluginMeta, escapeStringForRegex } from '@grafana/data';
import { filterPluginList } from './util';
describe('panel state utils', () => {
it('should include timeseries in a graph query', async () => {
const pluginsList = [
{ id: 'graph', name: 'Graph (old)' },
{ id: 'timeseries', name: 'Graph (old)' },
{ id: 'timeline', name: 'Timeline' },
] as PanelPluginMeta[];
const found = filterPluginList(pluginsList, escapeStringForRegex('gra'), { id: 'xyz' } as PanelPluginMeta);
expect(found.map((v) => v.id)).toEqual(['graph', 'timeseries']);
});
it('should handle escaped regex characters in the search query (e.g. -)', async () => {
const pluginsList = [
{ id: 'graph', name: 'Graph (old)' },
{ id: 'timeseries', name: 'Graph (old)' },
{ id: 'timeline', name: 'Timeline' },
{ id: 'panelwithdashes', name: 'Panel-With-Dashes' },
] as PanelPluginMeta[];
const found = filterPluginList(pluginsList, escapeStringForRegex('panel-'), { id: 'xyz' } as PanelPluginMeta);
expect(found.map((v) => v.id)).toEqual(['panelwithdashes']);
});
});