Commit 7e434fc0 by Torkel Ödegaard

refactor: moved graphite specs into plugins directory

parent cb7424ce
...@@ -25,6 +25,7 @@ module.exports = function(config) { ...@@ -25,6 +25,7 @@ module.exports = function(config) {
browsers: ['PhantomJS'], browsers: ['PhantomJS'],
captureTimeout: 60000, captureTimeout: 60000,
singleRun: true, singleRun: true,
autoWatchBatchDelay: 1000,
}); });
......
...@@ -5,9 +5,9 @@ define([ ...@@ -5,9 +5,9 @@ define([
'config', 'config',
'app/core/utils/datemath', 'app/core/utils/datemath',
'./directives', './directives',
'./queryCtrl', './query_ctrl',
'./funcEditor', './func_editor',
'./addGraphiteFunc', './add_graphite_func',
], ],
function (angular, _, $, config, dateMath) { function (angular, _, $, config, dateMath) {
'use strict'; 'use strict';
......
define([ ///<amd-dependency path="app/plugins/datasource/graphite/datasource" />
'./helpers', ///<amd-dependency path="test/specs/helpers" name="helpers" />
'app/plugins/datasource/graphite/datasource'
], function(helpers) {
'use strict';
describe('graphiteDatasource', function() { import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var helpers: any;
describe('graphiteDatasource', function() {
var ctx = new helpers.ServiceTestContext(); var ctx = new helpers.ServiceTestContext();
beforeEach(module('grafana.services')); beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase(['backendSrv'])); beforeEach(ctx.providePhase(['backendSrv']));
beforeEach(ctx.createService('GraphiteDatasource')); beforeEach(ctx.createService('GraphiteDatasource'));
...@@ -116,7 +116,5 @@ define([ ...@@ -116,7 +116,5 @@ define([
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc" />
'app/plugins/datasource/graphite/gfunc'
], function(gfunc) {
'use strict';
describe('when creating func instance from func names', function() { import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var gfunc: any;
describe('when creating func instance from func names', function() {
it('should return func instance', function() { it('should return func instance', function() {
var func = gfunc.createFuncInstance('sumSeries'); var func = gfunc.createFuncInstance('sumSeries');
expect(func).to.be.ok(); expect(func).to.be.ok();
...@@ -31,10 +31,9 @@ define([ ...@@ -31,10 +31,9 @@ define([
func.updateText(); func.updateText();
expect(func.text).to.equal("groupByNode(5, avg)"); expect(func.text).to.equal("groupByNode(5, avg)");
}); });
});
}); describe('when rendering func instance', function() {
describe('when rendering func instance', function() {
it('should handle single metric param', function() { it('should handle single metric param', function() {
var func = gfunc.createFuncInstance('sumSeries'); var func = gfunc.createFuncInstance('sumSeries');
...@@ -77,16 +76,16 @@ define([ ...@@ -77,16 +76,16 @@ define([
expect(func.render('#A')).to.equal("asPercent(#A, #B)"); expect(func.render('#A')).to.equal("asPercent(#A, #B)");
}); });
}); });
describe('when requesting function categories', function() { describe('when requesting function categories', function() {
it('should return function categories', function() { it('should return function categories', function() {
var catIndex = gfunc.getCategories(); var catIndex = gfunc.getCategories();
expect(catIndex.Special.length).to.be.greaterThan(8); expect(catIndex.Special.length).to.be.greaterThan(8);
}); });
}); });
describe('when updating func param', function() { describe('when updating func param', function() {
it('should update param value and update text representation', function() { it('should update param value and update text representation', function() {
var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true }); var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true });
func.updateParam('1h', 0); func.updateParam('1h', 0);
...@@ -99,9 +98,9 @@ define([ ...@@ -99,9 +98,9 @@ define([
func.updateParam('0.001', 0); func.updateParam('0.001', 0);
expect(func.params[0]).to.be('0.001'); expect(func.params[0]).to.be('0.001');
}); });
}); });
describe('when updating func param with optional second parameter', function() { describe('when updating func param with optional second parameter', function() {
it('should update value and text', function() { it('should update value and text', function() {
var func = gfunc.createFuncInstance('aliasByNode'); var func = gfunc.createFuncInstance('aliasByNode');
func.updateParam('1', 0); func.updateParam('1', 0);
...@@ -124,7 +123,5 @@ define([ ...@@ -124,7 +123,5 @@ define([
expect(func.params[1]).to.be(undefined); expect(func.params[1]).to.be(undefined);
expect(func.text).to.be('aliasByNode(4)'); expect(func.text).to.be('aliasByNode(4)');
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc"/>
'./helpers', ///<amd-dependency path="app/plugins/datasource/graphite/query_ctrl" />
'app/plugins/datasource/graphite/gfunc', ///<amd-dependency path="app/services/uiSegmentSrv" />
'app/plugins/datasource/graphite/queryCtrl', ///<amd-dependency path="test/specs/helpers" name="helpers" />
'app/services/uiSegmentSrv'
], function(helpers, gfunc) { import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
'use strict';
declare var gfunc: any;
describe('GraphiteQueryCtrl', function() { declare var helpers: any;
describe('GraphiteQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext(); var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.controllers')); beforeEach(angularMocks.module('grafana.controllers'));
beforeEach(module('grafana.services')); beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase()); beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('GraphiteQueryCtrl')); beforeEach(ctx.createControllerPhase('GraphiteQueryCtrl'));
...@@ -173,7 +175,4 @@ define([ ...@@ -173,7 +175,4 @@ define([
expect(ctx.scope.$parent.get_data.called).to.be(true); expect(ctx.scope.$parent.get_data.called).to.be(true);
}); });
}); });
});
}); });
...@@ -7,10 +7,15 @@ var it = _global.it; ...@@ -7,10 +7,15 @@ var it = _global.it;
var sinon = _global.sinon; var sinon = _global.sinon;
var expect = _global.expect; var expect = _global.expect;
var angularMocks = {
module: _global.module,
};
export { export {
beforeEach, beforeEach,
describe, describe,
it, it,
sinon, sinon,
expect expect,
angularMocks,
} }
...@@ -113,7 +113,7 @@ require([ ...@@ -113,7 +113,7 @@ require([
var specs = []; var specs = [];
for (var file in window.__karma__.files) { for (var file in window.__karma__.files) {
if (/base\/test\/specs.*/.test(file)) { if (/specs.*/.test(file)) {
file = file2moduleName(file); file = file2moduleName(file);
specs.push(file); specs.push(file);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment