mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Lots of progress on per series overrides
This commit is contained in:
68
src/test/specs/grafanaGraph-specs.js
Normal file
68
src/test/specs/grafanaGraph-specs.js
Normal file
@@ -0,0 +1,68 @@
|
||||
define([
|
||||
'./helpers',
|
||||
'angular',
|
||||
'jquery',
|
||||
'directives/grafanaGraph'
|
||||
], function(helpers, angular, $) {
|
||||
'use strict';
|
||||
|
||||
describe('grafanaGraph', function() {
|
||||
|
||||
beforeEach(module('grafana.directives'));
|
||||
|
||||
function graphScenario(desc, func) {
|
||||
describe(desc, function() {
|
||||
var ctx = {};
|
||||
ctx.setup = function (setupFunc) {
|
||||
beforeEach(inject(function($rootScope, $compile) {
|
||||
var scope = $rootScope.$new();
|
||||
var element = angular.element("<div style='width:500px' grafana-graph><div>");
|
||||
|
||||
scope.height = '200px';
|
||||
scope.panel = {
|
||||
legend: {},
|
||||
grid: {},
|
||||
y_formats: []
|
||||
};
|
||||
scope.dashboard = { timezone: 'browser' };
|
||||
scope.range = {
|
||||
from: new Date('2014-08-09 10:00:00'),
|
||||
to: new Date('2014-09-09 13:00:00')
|
||||
};
|
||||
|
||||
setupFunc(scope);
|
||||
|
||||
$compile(element)(scope);
|
||||
scope.$digest();
|
||||
$.plot = ctx.plotSpy = sinon.spy();
|
||||
|
||||
scope.$emit('render', []);
|
||||
ctx.plotData = ctx.plotSpy.getCall(0).args[1];
|
||||
ctx.plotOptions = ctx.plotSpy.getCall(0).args[2];
|
||||
}));
|
||||
};
|
||||
|
||||
func(ctx);
|
||||
});
|
||||
}
|
||||
|
||||
graphScenario('simple lines options', function(ctx) {
|
||||
ctx.setup(function(scope) {
|
||||
scope.panel.lines = true;
|
||||
scope.panel.fill = 5;
|
||||
scope.panel.linewidth = 3;
|
||||
scope.panel.steppedLine = true;
|
||||
});
|
||||
|
||||
it('should configure plot with correct options', function() {
|
||||
expect(ctx.plotOptions.series.lines.show).to.be(true);
|
||||
expect(ctx.plotOptions.series.lines.fill).to.be(0.5);
|
||||
expect(ctx.plotOptions.series.lines.lineWidth).to.be(3);
|
||||
expect(ctx.plotOptions.series.lines.steps).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ define([
|
||||
}
|
||||
return {
|
||||
from : kbn.parseDate(this.time.from),
|
||||
to : kbn.parseDate(this.time.to)
|
||||
to : kbn.parseDate(this.time.to)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
40
src/test/specs/seriesOverridesCtrl-specs.js
Normal file
40
src/test/specs/seriesOverridesCtrl-specs.js
Normal file
@@ -0,0 +1,40 @@
|
||||
define([
|
||||
'./helpers',
|
||||
'panels/graph/seriesOverridesCtrl'
|
||||
], function(helpers) {
|
||||
'use strict';
|
||||
|
||||
describe('SeriesOverridesCtrl', function() {
|
||||
var ctx = new helpers.ControllerTestContext();
|
||||
|
||||
beforeEach(module('grafana.services'));
|
||||
beforeEach(module('grafana.panels.graph'));
|
||||
|
||||
beforeEach(ctx.providePhase());
|
||||
beforeEach(ctx.createControllerPhase('SeriesOverridesCtrl'));
|
||||
|
||||
describe('Controller should init overrideMenu', function() {
|
||||
it('click should include option and value index', function() {
|
||||
expect(ctx.scope.overrideMenu[1].submenu[1].click).to.be('setOverride(1,1)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When setting an override', function() {
|
||||
beforeEach(function() {
|
||||
ctx.scope.setOverride(1, 0);
|
||||
});
|
||||
|
||||
it('should set override property', function() {
|
||||
expect(ctx.scope.override.lines).to.be(true);
|
||||
});
|
||||
|
||||
it('should update view model', function() {
|
||||
expect(ctx.scope.currentOverrides[0].name).to.be('Lines');
|
||||
expect(ctx.scope.currentOverrides[0].value).to.be('true');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -122,6 +122,8 @@ require([
|
||||
'specs/graphiteTargetCtrl-specs',
|
||||
'specs/influxdb-datasource-specs',
|
||||
'specs/graph-ctrl-specs',
|
||||
'specs/grafanaGraph-specs',
|
||||
'specs/seriesOverridesCtrl-specs',
|
||||
'specs/filterSrv-specs',
|
||||
'specs/kbn-format-specs',
|
||||
'specs/dashboardSrv-specs',
|
||||
|
||||
Reference in New Issue
Block a user