2017-12-21 08:39:31 +01:00
|
|
|
import { DataProcessor } from '../data_processor';
|
2019-08-01 23:16:29 -07:00
|
|
|
import { getProcessedDataFrames } from 'app/features/dashboard/state/PanelQueryState';
|
2016-09-23 17:12:10 +02:00
|
|
|
|
2018-09-04 15:55:41 +02:00
|
|
|
describe('Graph DataProcessor', () => {
|
2018-08-26 18:43:07 +02:00
|
|
|
const panel: any = {
|
2019-05-10 22:41:32 -07:00
|
|
|
xaxis: { mode: 'series' },
|
|
|
|
|
aliasColors: {},
|
2016-09-23 17:12:10 +02:00
|
|
|
};
|
2017-11-27 12:14:57 +01:00
|
|
|
|
2018-08-26 18:43:07 +02:00
|
|
|
const processor = new DataProcessor(panel);
|
2016-09-23 17:12:10 +02:00
|
|
|
|
2019-05-10 22:41:32 -07:00
|
|
|
describe('getTimeSeries from LegacyResponseData', () => {
|
|
|
|
|
// Try each type of data
|
2019-08-01 23:16:29 -07:00
|
|
|
const dataList = getProcessedDataFrames([
|
2019-05-10 22:41:32 -07:00
|
|
|
{
|
|
|
|
|
alias: 'First (time_series)',
|
|
|
|
|
datapoints: [[1, 1001], [2, 1002], [3, 1003]],
|
|
|
|
|
unit: 'watt',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'table_data',
|
|
|
|
|
columns: [
|
|
|
|
|
{ text: 'time' },
|
|
|
|
|
{ text: 'v1', unit: 'ohm' },
|
|
|
|
|
{ text: 'v2' }, // no unit
|
|
|
|
|
{ text: 'string' }, // skipped
|
2017-12-21 08:39:31 +01:00
|
|
|
],
|
2019-05-10 22:41:32 -07:00
|
|
|
rows: [
|
|
|
|
|
[1001, 0.1, 1.1, 'a'], // a
|
|
|
|
|
[1002, 0.2, 2.2, 'b'], // b
|
|
|
|
|
[1003, 0.3, 3.3, 'c'], // c
|
|
|
|
|
],
|
|
|
|
|
},
|
2017-12-19 16:06:54 +01:00
|
|
|
{
|
2019-05-10 22:41:32 -07:00
|
|
|
name: 'series',
|
|
|
|
|
fields: [
|
2019-08-15 09:18:51 -07:00
|
|
|
{ name: 'v1', values: [0.1, 0.2, 0.3] }, // first
|
|
|
|
|
{ name: 'v2', values: [1.1, 2.2, 3.3] }, // second
|
|
|
|
|
{ name: 'string', values: ['a', 'b', 'c'] }, // skip
|
|
|
|
|
{ name: 'time', values: [1001, 1002, 1003] }, // Time is last column
|
2017-12-21 08:39:31 +01:00
|
|
|
],
|
|
|
|
|
},
|
2019-05-10 22:41:32 -07:00
|
|
|
]);
|
2017-12-19 16:06:54 +01:00
|
|
|
|
2019-05-10 22:41:32 -07:00
|
|
|
it('Should return a new series for each field', () => {
|
|
|
|
|
panel.xaxis.mode = 'series';
|
|
|
|
|
const series = processor.getSeriesList({ dataList });
|
|
|
|
|
expect(series.length).toEqual(5);
|
2019-08-15 09:18:51 -07:00
|
|
|
|
2019-05-10 22:41:32 -07:00
|
|
|
expect(series).toMatchSnapshot();
|
2016-09-24 13:08:58 +02:00
|
|
|
});
|
|
|
|
|
|
2019-05-10 22:41:32 -07:00
|
|
|
it('Should return single histogram', () => {
|
|
|
|
|
panel.xaxis.mode = 'histogram';
|
|
|
|
|
const series = processor.getSeriesList({ dataList });
|
|
|
|
|
expect(series.length).toEqual(1);
|
|
|
|
|
expect(series).toMatchSnapshot();
|
2016-09-24 13:08:58 +02:00
|
|
|
});
|
|
|
|
|
});
|
2016-09-23 17:12:10 +02:00
|
|
|
});
|