|
|
@@ -23,11 +23,13 @@ describe('grafanaGraph', function() {
|
|
|
}));
|
|
|
|
|
|
beforeEach(angularMocks.inject(function($rootScope, $compile) {
|
|
|
+ var ctrl: any = {};
|
|
|
var scope = $rootScope.$new();
|
|
|
+ scope.ctrl = ctrl;
|
|
|
var element = angular.element("<div style='width:500px' grafana-graph><div>");
|
|
|
|
|
|
- scope.height = '200px';
|
|
|
- scope.panel = {
|
|
|
+ ctrl.height = '200px';
|
|
|
+ ctrl.panel = {
|
|
|
legend: {},
|
|
|
grid: { },
|
|
|
y_formats: [],
|
|
|
@@ -37,12 +39,12 @@ describe('grafanaGraph', function() {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- scope.panelRenderingComplete = sinon.spy();
|
|
|
- scope.appEvent = sinon.spy();
|
|
|
- scope.onAppEvent = sinon.spy();
|
|
|
- scope.hiddenSeries = {};
|
|
|
- scope.dashboard = { timezone: 'browser' };
|
|
|
- scope.range = {
|
|
|
+ $rootScope.onAppEvent = sinon.spy();
|
|
|
+ ctrl.otherPanelInFullscreenMode = sinon.spy();
|
|
|
+ ctrl.renderingCompleted = sinon.spy();
|
|
|
+ ctrl.hiddenSeries = {};
|
|
|
+ ctrl.dashboard = { timezone: 'browser' };
|
|
|
+ ctrl.range = {
|
|
|
from: new Date('2014-08-09 10:00:00'),
|
|
|
to: new Date('2014-09-09 13:00:00')
|
|
|
};
|
|
|
@@ -56,7 +58,7 @@ describe('grafanaGraph', function() {
|
|
|
alias: 'series2'
|
|
|
}));
|
|
|
|
|
|
- setupFunc(scope, ctx.data);
|
|
|
+ setupFunc(ctrl, ctx.data);
|
|
|
|
|
|
$compile(element)(scope);
|
|
|
scope.$digest();
|
|
|
@@ -73,11 +75,11 @@ describe('grafanaGraph', function() {
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.lines = true;
|
|
|
+ ctrl.panel.fill = 5;
|
|
|
+ ctrl.panel.linewidth = 3;
|
|
|
+ ctrl.panel.steppedLine = true;
|
|
|
});
|
|
|
|
|
|
it('should configure plot with correct options', function() {
|
|
|
@@ -89,8 +91,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('grid thresholds 100, 200', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.grid = {
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.grid = {
|
|
|
threshold1: 100,
|
|
|
threshold1Color: "#111",
|
|
|
threshold2: 200,
|
|
|
@@ -109,8 +111,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('inverted grid thresholds 200, 100', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.grid = {
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.grid = {
|
|
|
threshold1: 200,
|
|
|
threshold1Color: "#111",
|
|
|
threshold2: 100,
|
|
|
@@ -129,8 +131,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('grid thresholds from zero', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.grid = {
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.grid = {
|
|
|
threshold1: 0,
|
|
|
threshold1Color: "#111",
|
|
|
};
|
|
|
@@ -143,8 +145,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('when logBase is log 10', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.grid = {
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.grid = {
|
|
|
leftMax: null,
|
|
|
rightMax: null,
|
|
|
leftMin: null,
|
|
|
@@ -162,8 +164,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('should use timeStep for barWidth', function(ctx) {
|
|
|
- ctx.setup(function(scope, data) {
|
|
|
- scope.panel.bars = true;
|
|
|
+ ctx.setup(function(ctrl, data) {
|
|
|
+ ctrl.panel.bars = true;
|
|
|
data[0] = new TimeSeries({
|
|
|
datapoints: [[1,10],[2,20]],
|
|
|
alias: 'series1',
|
|
|
@@ -176,10 +178,10 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('series option overrides, fill & points', function(ctx) {
|
|
|
- ctx.setup(function(scope, data) {
|
|
|
- scope.panel.lines = true;
|
|
|
- scope.panel.fill = 5;
|
|
|
- scope.panel.seriesOverrides = [
|
|
|
+ ctx.setup(function(ctrl, data) {
|
|
|
+ ctrl.panel.lines = true;
|
|
|
+ ctrl.panel.fill = 5;
|
|
|
+ ctrl.panel.seriesOverrides = [
|
|
|
{ alias: 'test', fill: 0, points: true }
|
|
|
];
|
|
|
|
|
|
@@ -194,8 +196,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('should order series order according to zindex', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.seriesOverrides = [{ alias: 'series1', zindex: 2 }];
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.seriesOverrides = [{ alias: 'series1', zindex: 2 }];
|
|
|
});
|
|
|
|
|
|
it('should move zindex 2 last', function() {
|
|
|
@@ -205,8 +207,8 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('when series is hidden', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.hiddenSeries = {'series2': true};
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.hiddenSeries = {'series2': true};
|
|
|
});
|
|
|
|
|
|
it('should remove datapoints and disable stack', function() {
|
|
|
@@ -217,9 +219,9 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
graphScenario('when stack and percent', function(ctx) {
|
|
|
- ctx.setup(function(scope) {
|
|
|
- scope.panel.percentage = true;
|
|
|
- scope.panel.stack = true;
|
|
|
+ ctx.setup(function(ctrl) {
|
|
|
+ ctrl.panel.percentage = true;
|
|
|
+ ctrl.panel.stack = true;
|
|
|
});
|
|
|
|
|
|
it('should show percentage', function() {
|