fix tests
This commit is contained in:
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
|||||||
import mocks from '../../test-setup/mocks';
|
import mocks from '../../test-setup/mocks';
|
||||||
import { Datasource } from "../module";
|
import { Datasource } from "../module";
|
||||||
import { zabbixTemplateFormat } from "../datasource";
|
import { zabbixTemplateFormat } from "../datasource";
|
||||||
|
import { dateMath } from '@grafana/data';
|
||||||
|
|
||||||
describe('ZabbixDatasource', () => {
|
describe('ZabbixDatasource', () => {
|
||||||
let ctx = {};
|
let ctx = {};
|
||||||
@@ -41,7 +42,10 @@ describe('ZabbixDatasource', () => {
|
|||||||
item: {filter: ""}
|
item: {filter: ""}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
range: {from: 'now-7d', to: 'now'}
|
range: {
|
||||||
|
from: dateMath.parse('now-1h'),
|
||||||
|
to: dateMath.parse('now')
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should return an empty array when no targets are set', (done) => {
|
it('should return an empty array when no targets are set', (done) => {
|
||||||
@@ -59,7 +63,7 @@ describe('ZabbixDatasource', () => {
|
|||||||
let ranges = ['now-8d', 'now-169h', 'now-1M', 'now-1y'];
|
let ranges = ['now-8d', 'now-169h', 'now-1M', 'now-1y'];
|
||||||
|
|
||||||
_.forEach(ranges, range => {
|
_.forEach(ranges, range => {
|
||||||
ctx.options.range.from = range;
|
ctx.options.range.from = dateMath.parse(range);
|
||||||
ctx.ds.queryNumericData = jest.fn();
|
ctx.ds.queryNumericData = jest.fn();
|
||||||
ctx.ds.query(ctx.options);
|
ctx.ds.query(ctx.options);
|
||||||
|
|
||||||
@@ -76,7 +80,7 @@ describe('ZabbixDatasource', () => {
|
|||||||
let ranges = ['now-7d', 'now-168h', 'now-1h', 'now-30m', 'now-30s'];
|
let ranges = ['now-7d', 'now-168h', 'now-1h', 'now-30m', 'now-30s'];
|
||||||
|
|
||||||
_.forEach(ranges, range => {
|
_.forEach(ranges, range => {
|
||||||
ctx.options.range.from = range;
|
ctx.options.range.from = dateMath.parse(range);
|
||||||
ctx.ds.queryNumericData = jest.fn();
|
ctx.ds.queryNumericData = jest.fn();
|
||||||
ctx.ds.query(ctx.options);
|
ctx.ds.query(ctx.options);
|
||||||
|
|
||||||
@@ -108,24 +112,19 @@ describe('ZabbixDatasource', () => {
|
|||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
||||||
ctx.options = {
|
ctx.options.targets = [{
|
||||||
range: {from: 'now-1h', to: 'now'},
|
group: {filter: ""},
|
||||||
targets: [
|
host: {filter: "Zabbix server"},
|
||||||
{
|
application: {filter: ""},
|
||||||
group: {filter: ""},
|
item: {filter: "System information"},
|
||||||
host: {filter: "Zabbix server"},
|
textFilter: "",
|
||||||
application: {filter: ""},
|
useCaptureGroups: true,
|
||||||
item: {filter: "System information"},
|
mode: 2,
|
||||||
textFilter: "",
|
resultFormat: "table",
|
||||||
useCaptureGroups: true,
|
options: {
|
||||||
mode: 2,
|
skipEmptyValues: false
|
||||||
resultFormat: "table",
|
}
|
||||||
options: {
|
}];
|
||||||
skipEmptyValues: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return data in table format', (done) => {
|
it('should return data in table format', (done) => {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export function groupByRange(datapoints, groupByCallback) {
|
|||||||
frame_values.push(point[POINT_VALUE]);
|
frame_values.push(point[POINT_VALUE]);
|
||||||
}
|
}
|
||||||
const frame_value = groupByCallback(frame_values);
|
const frame_value = groupByCallback(frame_values);
|
||||||
return [ [frame_value, frame_start], [frame_value, frame_end] ];
|
return [[frame_value, frame_start], [frame_value, frame_end]];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ jest.mock('grafana/app/core/utils/datemath', () => {
|
|||||||
jest.mock('grafana/app/core/utils/kbn', () => {
|
jest.mock('grafana/app/core/utils/kbn', () => {
|
||||||
return {
|
return {
|
||||||
round_interval: n => n,
|
round_interval: n => n,
|
||||||
|
secondsToHms: n => n + 'ms'
|
||||||
};
|
};
|
||||||
}, {virtual: true});
|
}, {virtual: true});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user