mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix: fixed variable srv tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import '../all';
|
||||
import { VariableSrv } from '../variable_srv';
|
||||
import { DashboardModel } from '../../dashboard/dashboard_model';
|
||||
import moment from 'moment';
|
||||
import $q from 'q';
|
||||
|
||||
@@ -56,10 +57,12 @@ describe('VariableSrv', function(this: any) {
|
||||
return getVarMockConstructor(ctr, model, ctx);
|
||||
};
|
||||
|
||||
ctx.variableSrv.init({
|
||||
templating: { list: [] },
|
||||
updateSubmenuVisibility: () => {},
|
||||
});
|
||||
ctx.variableSrv.init(
|
||||
new DashboardModel({
|
||||
templating: { list: [] },
|
||||
updateSubmenuVisibility: () => {},
|
||||
})
|
||||
);
|
||||
|
||||
scenario.variable = ctx.variableSrv.createVariableFromModel(scenario.variableModel);
|
||||
ctx.variableSrv.addVariable(scenario.variable);
|
||||
|
||||
@@ -2,6 +2,7 @@ import '../all';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { VariableSrv } from '../variable_srv';
|
||||
import { DashboardModel } from '../../dashboard/dashboard_model';
|
||||
import $q from 'q';
|
||||
|
||||
describe('VariableSrv init', function(this: any) {
|
||||
@@ -56,9 +57,9 @@ describe('VariableSrv init', function(this: any) {
|
||||
ctx.variableSrv.datasourceSrv = ctx.datasourceSrv;
|
||||
|
||||
ctx.variableSrv.$location.search = () => scenario.urlParams;
|
||||
ctx.variableSrv.dashboard = {
|
||||
ctx.variableSrv.dashboard = new DashboardModel({
|
||||
templating: { list: scenario.variables },
|
||||
};
|
||||
});
|
||||
|
||||
await ctx.variableSrv.init(ctx.variableSrv.dashboard);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class VariableSrv {
|
||||
|
||||
init(dashboard) {
|
||||
this.dashboard = dashboard;
|
||||
this.dashboard.on('time-range-updated', this.onTimeRangeUpdated.bind(this));
|
||||
this.dashboard.events.on('time-range-updated', this.onTimeRangeUpdated.bind(this));
|
||||
|
||||
// create working class models representing variables
|
||||
this.variables = dashboard.templating.list = dashboard.templating.list.map(this.createVariableFromModel.bind(this));
|
||||
|
||||
Reference in New Issue
Block a user