fix tests

This commit is contained in:
Alexander Zobnin
2019-10-09 15:41:02 +03:00
parent 1827aa942a
commit 1d13520358
3 changed files with 22 additions and 22 deletions

View File

@@ -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,24 +112,19 @@ describe('ZabbixDatasource', () => {
}
]));
ctx.options = {
range: {from: 'now-1h', to: 'now'},
targets: [
{
group: {filter: ""},
host: {filter: "Zabbix server"},
application: {filter: ""},
item: {filter: "System information"},
textFilter: "",
useCaptureGroups: true,
mode: 2,
resultFormat: "table",
options: {
skipEmptyValues: false
}
}
],
};
ctx.options.targets = [{
group: {filter: ""},
host: {filter: "Zabbix server"},
application: {filter: ""},
item: {filter: "System information"},
textFilter: "",
useCaptureGroups: true,
mode: 2,
resultFormat: "table",
options: {
skipEmptyValues: false
}
}];
});
it('should return data in table format', (done) => {