Преглед изворни кода

feat(panels): fixed singlestat tests

Torkel Ödegaard пре 10 година
родитељ
комит
307c86fc28

+ 0 - 2
public/app/plugins/panel/singlestat/module.ts

@@ -230,8 +230,6 @@ function getColorForValue(data, value) {
       return data.colorMap[i];
       return data.colorMap[i];
     }
     }
   }
   }
-
-  console.log('first');
   return _.first(data.colorMap);
   return _.first(data.colorMap);
 }
 }
 
 

+ 4 - 7
public/app/plugins/panel/singlestat/specs/singlestat-specs.ts

@@ -9,9 +9,6 @@ import angular from 'angular';
 import helpers from '../../../../../test/specs/helpers';
 import helpers from '../../../../../test/specs/helpers';
 import {SingleStatCtrl} from '../controller';
 import {SingleStatCtrl} from '../controller';
 
 
-
-angular.module('grafana.controllers').controller('SingleStatCtrl', SingleStatCtrl);
-
 describe('SingleStatCtrl', function() {
 describe('SingleStatCtrl', function() {
   var ctx = new helpers.ControllerTestContext();
   var ctx = new helpers.ControllerTestContext();
 
 
@@ -25,7 +22,7 @@ describe('SingleStatCtrl', function() {
         beforeEach(angularMocks.module('grafana.controllers'));
         beforeEach(angularMocks.module('grafana.controllers'));
 
 
         beforeEach(ctx.providePhase());
         beforeEach(ctx.providePhase());
-        beforeEach(ctx.createControllerPhase('SingleStatCtrl'));
+        beforeEach(ctx.createPanelController(SingleStatCtrl));
 
 
         beforeEach(function() {
         beforeEach(function() {
           setupFunc();
           setupFunc();
@@ -33,9 +30,9 @@ describe('SingleStatCtrl', function() {
             data: [{target: 'test.cpu1', datapoints: ctx.datapoints}]
             data: [{target: 'test.cpu1', datapoints: ctx.datapoints}]
           }));
           }));
 
 
-          ctx.scope.refreshData(ctx.datasource);
+          ctx.ctrl.refreshData(ctx.datasource);
           ctx.scope.$digest();
           ctx.scope.$digest();
-          ctx.data = ctx.scope.data;
+          ctx.data = ctx.ctrl.data;
         });
         });
       };
       };
 
 
@@ -76,7 +73,7 @@ describe('SingleStatCtrl', function() {
   singleStatScenario('When value to text mapping is specified', function(ctx) {
   singleStatScenario('When value to text mapping is specified', function(ctx) {
     ctx.setup(function() {
     ctx.setup(function() {
       ctx.datapoints = [[10,1]];
       ctx.datapoints = [[10,1]];
-      ctx.scope.panel.valueMaps = [{value: '10', text: 'OK'}];
+      ctx.ctrl.panel.valueMaps = [{value: '10', text: 'OK'}];
     });
     });
 
 
     it('Should replace value with text', function() {
     it('Should replace value with text', function() {