From bbc5dae1d2308edb487f82ed755cd1ada2cee895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 7 Sep 2014 11:55:26 +0200 Subject: [PATCH] Working on better handling of variables and url init and state --- src/test/specs/helpers.js | 2 ++ src/test/specs/templateValuesSrv-specs.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/test/specs/helpers.js b/src/test/specs/helpers.js index 35cde542de6..81f0df7be7e 100644 --- a/src/test/specs/helpers.js +++ b/src/test/specs/helpers.js @@ -51,6 +51,7 @@ define([ self.templateSrv = new TemplateSrvStub(); self.timeSrv = new TimeSrvStub(); self.datasourceSrv = {}; + self.$routeParams = {}; this.providePhase = function(mocks) { return module(function($provide) { @@ -103,6 +104,7 @@ define([ this.replace = function(text) { return _.template(text, this.data, this.templateSettings); }; + this.init = function() {}; this.updateTemplateData = function() { }; this.variableExists = function() { return false; }; this.highlightVariablesAsHtml = function(str) { return str; }; diff --git a/src/test/specs/templateValuesSrv-specs.js b/src/test/specs/templateValuesSrv-specs.js index eb1b0225618..c0674a5cd75 100644 --- a/src/test/specs/templateValuesSrv-specs.js +++ b/src/test/specs/templateValuesSrv-specs.js @@ -10,7 +10,7 @@ define([ var ctx = new helpers.ServiceTestContext(); beforeEach(module('grafana.services')); - beforeEach(ctx.providePhase(['datasourceSrv', 'timeSrv', 'templateSrv'])); + beforeEach(ctx.providePhase(['datasourceSrv', 'timeSrv', 'templateSrv', "$routeParams"])); beforeEach(ctx.createService('templateValuesSrv')); describe('update interval variable options', function() { @@ -27,6 +27,20 @@ define([ }); }); + describe.only('should init values', function() { + var variables = [ + { name: 'test', current: { value: 'hej' }} + ]; + var dashboard = { templating: { list: variables } }; + + beforeEach(function() { + ctx.service.init(dashboard); + }); + + it('should update options array', function() { + }); + }); + function describeUpdateVariable(desc, fn) { describe(desc, function() { var scenario = {};