Browse Source

Merge remote-tracking branch 'origin/master' into pro

Torkel Ödegaard 11 years ago
parent
commit
6f0c6281e7
5 changed files with 66 additions and 19 deletions
  1. 1 1
      README.md
  2. 0 18
      grafana.sublime-project
  3. 2 0
      src/test/specs/helpers.js
  4. 62 0
      src/test/specs/row-ctrl-specs.js
  5. 1 0
      src/test/test-main.js

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-[Grafana](http://grafana.org) [![Build Status](https://api.travis-ci.org/grafana/grafana.svg)](https://travis-ci.org/grafana/grafana) [![Coverage Status](https://coveralls.io/repos/grafana/grafana/badge.png?branch=develop)](https://coveralls.io/r/grafana/grafana?branch=develop)
+[Grafana](http://grafana.org) [![Build Status](https://api.travis-ci.org/grafana/grafana.svg)](https://travis-ci.org/grafana/grafana) [![Coverage Status](https://coveralls.io/repos/grafana/grafana/badge.png)](https://coveralls.io/r/grafana/grafana)
 ================
 ================
 [Website](http://grafana.org) |
 [Website](http://grafana.org) |
 [Twitter](http://twitter.com/grafana) |
 [Twitter](http://twitter.com/grafana) |

+ 0 - 18
grafana.sublime-project

@@ -1,18 +0,0 @@
-{
-  "folders":
-  [
-    {
-      "follow_symlinks": true,
-      "path": ".",
-      "folder_exclude_patterns": [
-        "node_modules"
-      ]
-    }
-  ],
-  "settings":
-  {
-    "tab_size": 2,
-    "translate_tabs_to_spaces": true,
-    "trim_trailing_white_space_on_save": true
-  }
-}

+ 2 - 0
src/test/specs/helpers.js

@@ -24,7 +24,9 @@ define([
       return inject(function($controller, $rootScope, $q) {
       return inject(function($controller, $rootScope, $q) {
         self.scope = $rootScope.$new();
         self.scope = $rootScope.$new();
         self.scope.panel = {};
         self.scope.panel = {};
+        self.scope.row = { panels:[] };
         self.scope.filter = new FilterSrvStub();
         self.scope.filter = new FilterSrvStub();
+
         $rootScope.colors = [];
         $rootScope.colors = [];
         for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }
         for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }
 
 

+ 62 - 0
src/test/specs/row-ctrl-specs.js

@@ -0,0 +1,62 @@
+define([
+  './helpers',
+  'controllers/row'
+], function(helpers) {
+  'use strict';
+
+  describe('RowCtrl', function() {
+    var ctx = new helpers.ControllerTestContext();
+
+    beforeEach(module('grafana.controllers'));
+
+    beforeEach(ctx.providePhase());
+    beforeEach(ctx.createControllerPhase('RowCtrl'));
+
+    describe('when getting rowSpan', function() {
+      it('should return sum of panels spans', function() {
+        var spanLeft = ctx.scope.rowSpan({ panels: [{ span: 2 }, { span: 3 }] });
+        expect(spanLeft).to.be(5);
+      });
+    });
+
+    describe('when adding panel to row with 12 span panel', function() {
+      it('should split span in half and add panel with defaults', function() {
+        ctx.scope.row = { panels: [{ span: 12 }] };
+        ctx.scope.add_panel_default('graph');
+
+        expect(ctx.scope.row.panels[0].span).to.be(6);
+        expect(ctx.scope.row.panels[1].span).to.be(6);
+        expect(ctx.scope.row.panels[1].type).to.be('graph');
+      });
+    });
+
+    describe('when duplicating panel', function() {
+      it('should try to add it to same row', function() {
+        var panel = { span: 4, attr: '123' };
+        ctx.scope.row = { panels: [panel] };
+        ctx.scope.duplicatePanel(panel, ctx.scope.row);
+
+        expect(ctx.scope.row.panels[0].span).to.be(4);
+        expect(ctx.scope.row.panels[1].span).to.be(4);
+        expect(ctx.scope.row.panels[1].attr).to.be('123');
+      });
+    });
+
+    describe('when duplicating panel', function() {
+      it('should add row if there is no space left', function() {
+        var panel = { span: 12, attr: '123' };
+        ctx.scope.row = { panels: [panel] };
+        ctx.scope.dashboard = { rows: [ctx.scope.row] };
+
+        ctx.scope.duplicatePanel(panel, ctx.scope.row);
+
+        expect(ctx.scope.row.panels[0].span).to.be(12);
+        expect(ctx.scope.row.panels.length).to.be(1);
+        expect(ctx.scope.dashboard.rows[1].panels[0].attr).to.be('123');
+      });
+    });
+
+  });
+
+});
+

+ 1 - 0
src/test/test-main.js

@@ -117,6 +117,7 @@ require([
     'specs/lexer-specs',
     'specs/lexer-specs',
     'specs/parser-specs',
     'specs/parser-specs',
     'specs/gfunc-specs',
     'specs/gfunc-specs',
+    'specs/row-ctrl-specs',
     'specs/graphiteTargetCtrl-specs',
     'specs/graphiteTargetCtrl-specs',
     'specs/influxdb-datasource-specs',
     'specs/influxdb-datasource-specs',
     'specs/graph-ctrl-specs',
     'specs/graph-ctrl-specs',