mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Begin conversion
This commit is contained in:
@@ -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 = {
|
||||||
|
metricFindQuery: jest.fn(() => Promise.resolve([])),
|
||||||
|
getFuncDefs: jest.fn(() => Promise.resolve(gfunc.getFuncDefs('1.0'))),
|
||||||
|
getFuncDef: gfunc.getFuncDef,
|
||||||
|
waitForFuncDefsLoaded: jest.fn(() => Promise.resolve(null)),
|
||||||
|
createFuncInstance: gfunc.createFuncInstance,
|
||||||
|
|
||||||
|
};
|
||||||
|
let ctx = {
|
||||||
|
|
||||||
beforeEach(angularMocks.module('grafana.core'));
|
};
|
||||||
beforeEach(angularMocks.module('grafana.controllers'));
|
|
||||||
beforeEach(angularMocks.module('grafana.services'));
|
|
||||||
beforeEach(
|
|
||||||
angularMocks.module(function($compileProvider) {
|
|
||||||
$compileProvider.preAssignBindingsEnabled(true);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
beforeEach(ctx.providePhase());
|
// beforeEach(angularMocks.module('grafana.core'));
|
||||||
beforeEach(
|
// beforeEach(angularMocks.module('grafana.controllers'));
|
||||||
angularMocks.inject(($rootScope, $controller, $q) => {
|
// beforeEach(angularMocks.module('grafana.services'));
|
||||||
ctx.$q = $q;
|
// beforeEach(
|
||||||
ctx.scope = $rootScope.$new();
|
// angularMocks.module(function($compileProvider) {
|
||||||
ctx.target = { target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)' };
|
// $compileProvider.preAssignBindingsEnabled(true);
|
||||||
ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
|
// })
|
||||||
ctx.datasource.getFuncDefs = sinon.stub().returns(ctx.$q.when(gfunc.getFuncDefs('1.0')));
|
// );
|
||||||
ctx.datasource.getFuncDef = gfunc.getFuncDef;
|
|
||||||
ctx.datasource.waitForFuncDefsLoaded = sinon.stub().returns(ctx.$q.when(null));
|
|
||||||
ctx.datasource.createFuncInstance = gfunc.createFuncInstance;
|
|
||||||
ctx.panelCtrl = { panel: {} };
|
|
||||||
ctx.panelCtrl = {
|
|
||||||
panel: {
|
|
||||||
targets: [ctx.target],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
ctx.panelCtrl.refresh = sinon.spy();
|
|
||||||
|
|
||||||
ctx.ctrl = $controller(
|
//beforeEach(ctx.providePhase());
|
||||||
GraphiteQueryCtrl,
|
// beforeEach(
|
||||||
{ $scope: ctx.scope },
|
// angularMocks.inject(($rootScope, $controller, $q) => {
|
||||||
{
|
// ctx.$q = $q;
|
||||||
panelCtrl: ctx.panelCtrl,
|
// ctx.scope = $rootScope.$new();
|
||||||
datasource: ctx.datasource,
|
// ctx.target = { target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)' };
|
||||||
target: ctx.target,
|
// ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
|
||||||
}
|
// ctx.datasource.getFuncDefs = sinon.stub().returns(ctx.$q.when(gfunc.getFuncDefs('1.0')));
|
||||||
);
|
// ctx.datasource.getFuncDef = gfunc.getFuncDef;
|
||||||
ctx.scope.$digest();
|
// ctx.datasource.waitForFuncDefsLoaded = sinon.stub().returns(ctx.$q.when(null));
|
||||||
})
|
// ctx.datasource.createFuncInstance = gfunc.createFuncInstance;
|
||||||
);
|
// ctx.panelCtrl = { panel: {} };
|
||||||
|
// ctx.panelCtrl = {
|
||||||
|
// panel: {
|
||||||
|
// targets: [ctx.target],
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
// 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() {
|
||||||
Reference in New Issue
Block a user