From 6f43cbf66596ea37dad7b5e56350310248a3f749 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Wed, 23 Sep 2015 13:24:59 +0530 Subject: [PATCH] Added unit tests for all and multi format options. --- public/test/specs/templateSrv-specs.js | 10 ++++++++++ public/test/specs/templateValuesSrv-specs.js | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/public/test/specs/templateSrv-specs.js b/public/test/specs/templateSrv-specs.js index 1b43adff63e..36f303e55c6 100644 --- a/public/test/specs/templateSrv-specs.js +++ b/public/test/specs/templateSrv-specs.js @@ -81,6 +81,16 @@ define([ expect(result).to.be('(test|test2)'); }); + it('multi value and pipe should render pipe string', function() { + var result = _templateSrv.renderVariableValue({ + multiFormat: 'pipe', + current: { + value: ['test','test2'], + } + }); + expect(result).to.be('test|test2'); + }); + }); describe('can check if variable exists', function() { diff --git a/public/test/specs/templateValuesSrv-specs.js b/public/test/specs/templateValuesSrv-specs.js index feb13c37130..4c5b7e19a69 100644 --- a/public/test/specs/templateValuesSrv-specs.js +++ b/public/test/specs/templateValuesSrv-specs.js @@ -349,6 +349,17 @@ define([ }); }); + describeUpdateVariable('with include all pipe all values', function(scenario) { + scenario.setup(function() { + scenario.variable = { type: 'query', query: 'apps.*', name: 'test', includeAll: true, allFormat: 'pipe' }; + scenario.queryResult = [{text: 'backend1'}, {text: 'backend2'}, { text: 'backend3'}]; + }); + + it('should add pipe delimited string', function() { + expect(scenario.variable.options[0].value).to.be('backend1|backend2|backend3'); + }); + }); + }); });