mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Fix: Fixes panel editor crash when switching to Promehteus Fixes: #18600 * Refactor: Adds tests
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { getQueryHints } from './query_hints';
|
|
|
|
describe('getQueryHints', () => {
|
|
describe('when called without datapoints in series', () => {
|
|
it('then it should use rows instead and return correct hint', () => {
|
|
const series = [
|
|
{
|
|
fields: [
|
|
{
|
|
name: 'Some Name',
|
|
},
|
|
],
|
|
rows: [[1], [2]],
|
|
},
|
|
];
|
|
|
|
const result = getQueryHints('up', series);
|
|
expect(result).toEqual([
|
|
{
|
|
fix: { action: { query: 'up', type: 'ADD_RATE' }, label: 'Fix by adding rate().' },
|
|
label: 'Time series is monotonically increasing.',
|
|
type: 'APPLY_RATE',
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe('when called without datapoints and rows in series', () => {
|
|
it('then it should use an empty array and return null', () => {
|
|
const series = [
|
|
{
|
|
fields: [
|
|
{
|
|
name: 'Some Name',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
const result = getQueryHints('up', series);
|
|
expect(result).toEqual(null);
|
|
});
|
|
});
|
|
});
|