Commit 7e434fc0 by Torkel Ödegaard

refactor: moved graphite specs into plugins directory

parent cb7424ce
......@@ -25,6 +25,7 @@ module.exports = function(config) {
browsers: ['PhantomJS'],
captureTimeout: 60000,
singleRun: true,
autoWatchBatchDelay: 1000,
});
......
......@@ -5,9 +5,9 @@ define([
'config',
'app/core/utils/datemath',
'./directives',
'./queryCtrl',
'./funcEditor',
'./addGraphiteFunc',
'./query_ctrl',
'./func_editor',
'./add_graphite_func',
],
function (angular, _, $, config, dateMath) {
'use strict';
......
define([
'./helpers',
'app/plugins/datasource/graphite/datasource'
], function(helpers) {
'use strict';
///<amd-dependency path="app/plugins/datasource/graphite/datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
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();
beforeEach(module('grafana.services'));
beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase(['backendSrv']));
beforeEach(ctx.createService('GraphiteDatasource'));
......@@ -116,7 +116,5 @@ define([
});
});
});
define([
'app/plugins/datasource/graphite/gfunc'
], function(gfunc) {
'use strict';
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc" />
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() {
var func = gfunc.createFuncInstance('sumSeries');
expect(func).to.be.ok();
......@@ -31,10 +31,9 @@ define([
func.updateText();
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() {
var func = gfunc.createFuncInstance('sumSeries');
......@@ -77,16 +76,16 @@ define([
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() {
var catIndex = gfunc.getCategories();
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() {
var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true });
func.updateParam('1h', 0);
......@@ -99,9 +98,9 @@ define([
func.updateParam('0.001', 0);
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() {
var func = gfunc.createFuncInstance('aliasByNode');
func.updateParam('1', 0);
......@@ -124,7 +123,5 @@ define([
expect(func.params[1]).to.be(undefined);
expect(func.text).to.be('aliasByNode(4)');
});
});
});
define([
'./helpers',
'app/plugins/datasource/graphite/gfunc',
'app/plugins/datasource/graphite/queryCtrl',
'app/services/uiSegmentSrv'
], function(helpers, gfunc) {
'use strict';
describe('GraphiteQueryCtrl', function() {
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc"/>
///<amd-dependency path="app/plugins/datasource/graphite/query_ctrl" />
///<amd-dependency path="app/services/uiSegmentSrv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var gfunc: any;
declare var helpers: any;
describe('GraphiteQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.controllers'));
beforeEach(module('grafana.services'));
beforeEach(angularMocks.module('grafana.controllers'));
beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('GraphiteQueryCtrl'));
......@@ -173,7 +175,4 @@ define([
expect(ctx.scope.$parent.get_data.called).to.be(true);
});
});
});
});
......@@ -7,10 +7,15 @@ var it = _global.it;
var sinon = _global.sinon;
var expect = _global.expect;
var angularMocks = {
module: _global.module,
};
export {
beforeEach,
describe,
it,
sinon,
expect
expect,
angularMocks,
}
......@@ -113,7 +113,7 @@ require([
var specs = [];
for (var file in window.__karma__.files) {
if (/base\/test\/specs.*/.test(file)) {
if (/specs.*/.test(file)) {
file = file2moduleName(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