fix tests
This commit is contained in:
@@ -2,6 +2,7 @@ import _ from 'lodash';
|
||||
import mocks from '../../test-setup/mocks';
|
||||
import { Datasource } from "../module";
|
||||
import { zabbixTemplateFormat } from "../datasource";
|
||||
import { dateMath } from '@grafana/data';
|
||||
|
||||
describe('ZabbixDatasource', () => {
|
||||
let ctx = {};
|
||||
@@ -41,7 +42,10 @@ describe('ZabbixDatasource', () => {
|
||||
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) => {
|
||||
@@ -59,7 +63,7 @@ describe('ZabbixDatasource', () => {
|
||||
let ranges = ['now-8d', 'now-169h', 'now-1M', 'now-1y'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.options.range.from = dateMath.parse(range);
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
@@ -76,7 +80,7 @@ describe('ZabbixDatasource', () => {
|
||||
let ranges = ['now-7d', 'now-168h', 'now-1h', 'now-30m', 'now-30s'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.options.range.from = dateMath.parse(range);
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
@@ -108,10 +112,7 @@ describe('ZabbixDatasource', () => {
|
||||
}
|
||||
]));
|
||||
|
||||
ctx.options = {
|
||||
range: {from: 'now-1h', to: 'now'},
|
||||
targets: [
|
||||
{
|
||||
ctx.options.targets = [{
|
||||
group: {filter: ""},
|
||||
host: {filter: "Zabbix server"},
|
||||
application: {filter: ""},
|
||||
@@ -123,9 +124,7 @@ describe('ZabbixDatasource', () => {
|
||||
options: {
|
||||
skipEmptyValues: false
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
}];
|
||||
});
|
||||
|
||||
it('should return data in table format', (done) => {
|
||||
|
||||
@@ -147,7 +147,7 @@ export function groupByRange(datapoints, groupByCallback) {
|
||||
frame_values.push(point[POINT_VALUE]);
|
||||
}
|
||||
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', () => {
|
||||
return {
|
||||
round_interval: n => n,
|
||||
secondsToHms: n => n + 'ms'
|
||||
};
|
||||
}, {virtual: true});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user