Commit 25c82335 by Tobias Skarhed

Begin conversion

parent 35efb7c2
...@@ -6,48 +6,59 @@ import helpers from 'test/specs/helpers'; ...@@ -6,48 +6,59 @@ import helpers from 'test/specs/helpers';
import { GraphiteQueryCtrl } from '../query_ctrl'; import { GraphiteQueryCtrl } from '../query_ctrl';
describe('GraphiteQueryCtrl', function() { describe('GraphiteQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext();
let datasource = {
beforeEach(angularMocks.module('grafana.core')); metricFindQuery: jest.fn(() => Promise.resolve([])),
beforeEach(angularMocks.module('grafana.controllers')); getFuncDefs: jest.fn(() => Promise.resolve(gfunc.getFuncDefs('1.0'))),
beforeEach(angularMocks.module('grafana.services')); getFuncDef: gfunc.getFuncDef,
beforeEach( waitForFuncDefsLoaded: jest.fn(() => Promise.resolve(null)),
angularMocks.module(function($compileProvider) { createFuncInstance: gfunc.createFuncInstance,
$compileProvider.preAssignBindingsEnabled(true);
}) };
); let ctx = {
beforeEach(ctx.providePhase()); };
beforeEach(
angularMocks.inject(($rootScope, $controller, $q) => { // beforeEach(angularMocks.module('grafana.core'));
ctx.$q = $q; // beforeEach(angularMocks.module('grafana.controllers'));
ctx.scope = $rootScope.$new(); // beforeEach(angularMocks.module('grafana.services'));
ctx.target = { target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)' }; // beforeEach(
ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([])); // angularMocks.module(function($compileProvider) {
ctx.datasource.getFuncDefs = sinon.stub().returns(ctx.$q.when(gfunc.getFuncDefs('1.0'))); // $compileProvider.preAssignBindingsEnabled(true);
ctx.datasource.getFuncDef = gfunc.getFuncDef; // })
ctx.datasource.waitForFuncDefsLoaded = sinon.stub().returns(ctx.$q.when(null)); // );
ctx.datasource.createFuncInstance = gfunc.createFuncInstance;
ctx.panelCtrl = { panel: {} }; //beforeEach(ctx.providePhase());
ctx.panelCtrl = { // beforeEach(
panel: { // angularMocks.inject(($rootScope, $controller, $q) => {
targets: [ctx.target], // ctx.$q = $q;
}, // ctx.scope = $rootScope.$new();
}; // ctx.target = { target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)' };
ctx.panelCtrl.refresh = sinon.spy(); // ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
// ctx.datasource.getFuncDefs = sinon.stub().returns(ctx.$q.when(gfunc.getFuncDefs('1.0')));
ctx.ctrl = $controller( // ctx.datasource.getFuncDef = gfunc.getFuncDef;
GraphiteQueryCtrl, // ctx.datasource.waitForFuncDefsLoaded = sinon.stub().returns(ctx.$q.when(null));
{ $scope: ctx.scope }, // ctx.datasource.createFuncInstance = gfunc.createFuncInstance;
{ // ctx.panelCtrl = { panel: {} };
panelCtrl: ctx.panelCtrl, // ctx.panelCtrl = {
datasource: ctx.datasource, // panel: {
target: ctx.target, // targets: [ctx.target],
} // },
); // };
ctx.scope.$digest(); // ctx.panelCtrl.refresh = sinon.spy();
})
); // ctx.ctrl = $controller(
// GraphiteQueryCtrl,
// { $scope: ctx.scope },
// {
// panelCtrl: ctx.panelCtrl,
// datasource: ctx.datasource,
// target: ctx.target,
// }
// );
// ctx.scope.$digest();
// })
// );
describe('init', function() { describe('init', function() {
it('should validate metric key exists', function() { it('should validate metric key exists', function() {
......
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