From b620c7457d95728a71be8d6606a916f35ee42da3 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 13 Dec 2016 10:45:40 +0100 Subject: [PATCH] test(query_editor): adds test for nesting queries in targetFull --- .../graphite/specs/query_ctrl_specs.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts index 8c191bba528..663400a7dd5 100644 --- a/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts +++ b/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts @@ -160,4 +160,27 @@ describe('GraphiteQueryCtrl', function() { expect(ctx.panelCtrl.refresh.called).to.be(true); }); }); + + describe('when updating targets with nested query', function() { + beforeEach(function() { + ctx.ctrl.target.target = 'scaleToSeconds(#A)'; + ctx.ctrl.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([{expandable: false}])); + ctx.ctrl.parseTarget(); + + ctx.ctrl.panelCtrl.panel.targets = [ { + target: 'nested.query.count', + refId: 'A' + }]; + + ctx.ctrl.updateModelTarget(); + }); + + it('target should remain the same', function() { + expect(ctx.ctrl.target.target).to.be('scaleToSeconds(#A)'); + }); + + it('targetFull should include nexted queries', function() { + expect(ctx.ctrl.target.targetFull).to.be('scaleToSeconds(nested.query.count)'); + }); + }); });