Initial unit tests (using Mocha and Chai asserts).

This commit is contained in:
Alexander Zobnin
2016-08-14 11:58:23 +03:00
parent 2882a48f25
commit d247fc8a99
5 changed files with 136 additions and 8 deletions

View File

@@ -0,0 +1,40 @@
import {Datasource} from "../module";
import Q from "q";
describe('ZabbixDatasource', function() {
var ctx = {};
beforeEach(function() {
ctx.instanceSettings = {
jsonData: {
username: 'zabbix',
password: 'zabbix',
trends: false
}
};
ctx.$q = Q;
ctx.templateSrv = {};
ctx.alertSrv = {};
ctx.zabbixAPIService = function() {};
ctx.ZabbixCachingProxy = function() {};
ctx.QueryProcessor = function() {};
ctx.ds = new Datasource(ctx.instanceSettings, ctx.$q, ctx.templateSrv, ctx.alertSrv,
ctx.zabbixAPIService, ctx.ZabbixCachingProxy, ctx.QueryProcessor);
});
describe('When querying data', function() {
it('should return an empty array when no targets are set', function(done) {
var options = {
targets: [],
range: {from: null, to: null}
};
ctx.ds.query(options).then(function(result) {
expect(result.data).to.have.length(0);
done();
});
});
});
});