Bläddra i källkod

Merge pull request #1272 from matschaffer/plugin-spec-support

Allow for plugin testing.
Torkel Ödegaard 11 år sedan
förälder
incheckning
7be2105fd9

+ 1 - 1
src/test/specs/graph-ctrl-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'panels/graph/module'
   'panels/graph/module'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/graph-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'angular',
   'angular',
   'jquery',
   'jquery',
   'components/timeSeries',
   'components/timeSeries',

+ 1 - 1
src/test/specs/graphiteDatasource-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'services/graphite/graphiteDatasource'
   'services/graphite/graphiteDatasource'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/graphiteTargetCtrl-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'services/graphite/gfunc',
   'services/graphite/gfunc',
   'controllers/graphiteTarget'
   'controllers/graphiteTarget'
 ], function(helpers, gfunc) {
 ], function(helpers, gfunc) {

+ 1 - 1
src/test/specs/influxdb-datasource-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'services/influxdb/influxdbDatasource'
   'services/influxdb/influxdbDatasource'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/row-ctrl-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'controllers/row'
   'controllers/row'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/seriesOverridesCtrl-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'panels/graph/seriesOverridesCtrl'
   'panels/graph/seriesOverridesCtrl'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/sharePanelCtrl-specs.js

@@ -1,5 +1,5 @@
 define([
 define([
-  './helpers',
+  'helpers',
   'controllers/sharePanelCtrl'
   'controllers/sharePanelCtrl'
 ], function(helpers) {
 ], function(helpers) {
   'use strict';
   'use strict';

+ 1 - 1
src/test/specs/templateValuesSrv-specs.js

@@ -1,6 +1,6 @@
 define([
 define([
   'mocks/dashboard-mock',
   'mocks/dashboard-mock',
-  './helpers',
+  'helpers',
   'moment',
   'moment',
   'services/templateValuesSrv'
   'services/templateValuesSrv'
 ], function(dashboardMock, helpers, moment) {
 ], function(dashboardMock, helpers, moment) {

+ 1 - 1
src/test/specs/timeSrv-specs.js

@@ -1,6 +1,6 @@
 define([
 define([
   'mocks/dashboard-mock',
   'mocks/dashboard-mock',
-  './helpers',
+  'helpers',
   'lodash',
   'lodash',
   'services/timeSrv'
   'services/timeSrv'
 ], function(dashboardMock, helpers, _) {
 ], function(dashboardMock, helpers, _) {

+ 12 - 5
src/test/test-main.js

@@ -4,7 +4,8 @@ require.config({
   paths: {
   paths: {
     specs:                 '../test/specs',
     specs:                 '../test/specs',
     mocks:                 '../test/mocks',
     mocks:                 '../test/mocks',
-    config:                '../config.sample',
+    helpers:               '../test/specs/helpers',
+    config:                ['../config', '../config.sample'],
     kbn:                   'components/kbn',
     kbn:                   'components/kbn',
     store:                 'components/store',
     store:                 'components/store',
 
 
@@ -96,9 +97,10 @@ require.config({
 
 
 require([
 require([
   'angular',
   'angular',
+  'config',
   'angularMocks',
   'angularMocks',
   'app',
   'app',
-], function(angular) {
+], function(angular, config) {
   'use strict';
   'use strict';
 
 
   for (var file in window.__karma__.files) {
   for (var file in window.__karma__.files) {
@@ -113,7 +115,7 @@ require([
   angular.module('grafana.panels', []);
   angular.module('grafana.panels', []);
   angular.module('grafana.filters', []);
   angular.module('grafana.filters', []);
 
 
-  require([
+  var specs = [
     'specs/lexer-specs',
     'specs/lexer-specs',
     'specs/parser-specs',
     'specs/parser-specs',
     'specs/gfunc-specs',
     'specs/gfunc-specs',
@@ -135,9 +137,14 @@ require([
     'specs/kbn-format-specs',
     'specs/kbn-format-specs',
     'specs/dashboardSrv-specs',
     'specs/dashboardSrv-specs',
     'specs/dashboardViewStateSrv-specs'
     'specs/dashboardViewStateSrv-specs'
-  ], function () {
-    window.__karma__.start();
+  ];
+
+  var pluginSpecs = (config.plugins.specs || []).map(function (spec) {
+    return '../plugins/' + spec;
   });
   });
 
 
+  require(specs.concat(pluginSpecs), function () {
+    window.__karma__.start();
+  });
 });
 });
 
 

+ 1 - 0
tasks/options/jscs.js

@@ -3,6 +3,7 @@ module.exports = function(config) {
     src: [
     src: [
       'Gruntfile.js',
       'Gruntfile.js',
       '<%= srcDir %>/app/**/*.js',
       '<%= srcDir %>/app/**/*.js',
+      '<%= srcDir %>/plugins/**/*.js',
       '!<%= srcDir %>/app/panels/*/{lib,leaflet}/*',
       '!<%= srcDir %>/app/panels/*/{lib,leaflet}/*',
       '!<%= srcDir %>/app/dashboards/*'
       '!<%= srcDir %>/app/dashboards/*'
     ],
     ],