2014-08-07 18:17:26 +02:00
|
|
|
define([
|
2014-12-23 12:01:50 -08:00
|
|
|
'helpers',
|
2015-02-02 21:59:04 +01:00
|
|
|
'features/panel/panelSrv',
|
2014-08-07 18:17:26 +02:00
|
|
|
'panels/graph/module'
|
|
|
|
], function(helpers) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
describe('GraphCtrl', function() {
|
|
|
|
var ctx = new helpers.ControllerTestContext();
|
|
|
|
|
|
|
|
beforeEach(module('grafana.services'));
|
|
|
|
beforeEach(module('grafana.panels.graph'));
|
|
|
|
|
|
|
|
beforeEach(ctx.providePhase());
|
|
|
|
beforeEach(ctx.createControllerPhase('GraphCtrl'));
|
|
|
|
|
|
|
|
describe('get_data with 2 series', function() {
|
|
|
|
beforeEach(function() {
|
|
|
|
ctx.annotationsSrv.getAnnotations = sinon.stub().returns(ctx.$q.when([]));
|
|
|
|
ctx.datasource.query = sinon.stub().returns(ctx.$q.when({
|
|
|
|
data: [
|
|
|
|
{ target: 'test.cpu1', datapoints: [[1, 10]]},
|
|
|
|
{ target: 'test.cpu2', datapoints: [[1, 10]]}
|
|
|
|
]
|
|
|
|
}));
|
|
|
|
ctx.scope.render = sinon.spy();
|
|
|
|
ctx.scope.get_data();
|
|
|
|
ctx.scope.$digest();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should send time series to render', function() {
|
|
|
|
var data = ctx.scope.render.getCall(0).args[0];
|
|
|
|
expect(data.length).to.be(2);
|
|
|
|
});
|
2014-10-24 14:51:45 -04:00
|
|
|
|
|
|
|
describe('get_data failure following success', function() {
|
|
|
|
beforeEach(function() {
|
|
|
|
ctx.datasource.query = sinon.stub().returns(ctx.$q.reject('Datasource Error'));
|
|
|
|
ctx.scope.get_data();
|
|
|
|
ctx.scope.$digest();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-08-07 18:17:26 +02:00
|
|
|
});
|
2014-09-04 14:08:31 +02:00
|
|
|
|
2014-08-07 18:17:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|