Commit b95d64e7 by Torkel Ödegaard

fix: fixed variable srv tests

parent 936fe560
import '../all'; import '../all';
import { VariableSrv } from '../variable_srv'; import { VariableSrv } from '../variable_srv';
import { DashboardModel } from '../../dashboard/dashboard_model';
import moment from 'moment'; import moment from 'moment';
import $q from 'q'; import $q from 'q';
...@@ -56,10 +57,12 @@ describe('VariableSrv', function(this: any) { ...@@ -56,10 +57,12 @@ describe('VariableSrv', function(this: any) {
return getVarMockConstructor(ctr, model, ctx); return getVarMockConstructor(ctr, model, ctx);
}; };
ctx.variableSrv.init({ ctx.variableSrv.init(
new DashboardModel({
templating: { list: [] }, templating: { list: [] },
updateSubmenuVisibility: () => {}, updateSubmenuVisibility: () => {},
}); })
);
scenario.variable = ctx.variableSrv.createVariableFromModel(scenario.variableModel); scenario.variable = ctx.variableSrv.createVariableFromModel(scenario.variableModel);
ctx.variableSrv.addVariable(scenario.variable); ctx.variableSrv.addVariable(scenario.variable);
......
...@@ -2,6 +2,7 @@ import '../all'; ...@@ -2,6 +2,7 @@ import '../all';
import _ from 'lodash'; import _ from 'lodash';
import { VariableSrv } from '../variable_srv'; import { VariableSrv } from '../variable_srv';
import { DashboardModel } from '../../dashboard/dashboard_model';
import $q from 'q'; import $q from 'q';
describe('VariableSrv init', function(this: any) { describe('VariableSrv init', function(this: any) {
...@@ -56,9 +57,9 @@ describe('VariableSrv init', function(this: any) { ...@@ -56,9 +57,9 @@ describe('VariableSrv init', function(this: any) {
ctx.variableSrv.datasourceSrv = ctx.datasourceSrv; ctx.variableSrv.datasourceSrv = ctx.datasourceSrv;
ctx.variableSrv.$location.search = () => scenario.urlParams; ctx.variableSrv.$location.search = () => scenario.urlParams;
ctx.variableSrv.dashboard = { ctx.variableSrv.dashboard = new DashboardModel({
templating: { list: scenario.variables }, templating: { list: scenario.variables },
}; });
await ctx.variableSrv.init(ctx.variableSrv.dashboard); await ctx.variableSrv.init(ctx.variableSrv.dashboard);
......
...@@ -18,7 +18,7 @@ export class VariableSrv { ...@@ -18,7 +18,7 @@ export class VariableSrv {
init(dashboard) { init(dashboard) {
this.dashboard = 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 // create working class models representing variables
this.variables = dashboard.templating.list = dashboard.templating.list.map(this.createVariableFromModel.bind(this)); this.variables = dashboard.templating.list = dashboard.templating.list.map(this.createVariableFromModel.bind(this));
......
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