text: /*! grafana - v2.5.0 - 2015-10-28
   * Copyright (c) 2015 Torkel Ödegaard; Licensed Apache-2.0 */
  
  define(["require","exports","test/specs/helpers","test/lib/common","app/plugins/datasource/graphite/datasource"],function(a,b,c,d){d.describe("graphiteDatasource",function(){var a=new c.ServiceTestContext;d.beforeEach(d.angularMocks.module("grafana.services")),d.beforeEach(a.providePhase(["backendSrv"])),d.beforeEach(a.createService("GraphiteDatasource")),d.beforeEach(function(){a.ds=new a.service({url:[""]})}),d.describe("When querying influxdb with one target using query editor target spec",function(){var b,c,e={rangeRaw:{from:"now-1h",to:"now"},targets:[{target:"prod1.count"},{target:"prod2.count"}],maxDataPoints:500};d.beforeEach(function(){a.backendSrv.datasourceRequest=function(b){return c=b,a.$q.when({data:[{target:"prod1.count",datapoints:[[10,1],[12,1]]}]})},a.ds.query(e).then(function(a){b=a}),a.$rootScope.$apply()}),d.it("should generate the correct query",function(){d.expect(c.url).to.be("/render")}),d.it("should query correctly",function(){var a=c.data.split("&");d.expect(a).to.contain("target=prod1.count"),d.expect(a).to.contain("target=prod2.count"),d.expect(a).to.contain("from=-1h"),d.expect(a).to.contain("until=now")}),d.it("should exclude undefined params",function(){var a=c.data.split("&");d.expect(a).to.not.contain("cacheTimeout=undefined")}),d.it("should return series list",function(){d.expect(b.data.length).to.be(1),d.expect(b.data[0].target).to.be("prod1.count")}),d.it("should convert to millisecond resolution",function(){d.expect(b.data[0].datapoints[0][0]).to.be(10)})}),d.describe("building graphite params",function(){d.it("should uri escape targets",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"prod1.{test,test2}"},{target:"prod2.count"}]});d.expect(b).to.contain("target=prod1.%7Btest%2Ctest2%7D")}),d.it("should replace target placeholder",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"series1"},{target:"series2"},{target:"asPercent(#A,#B)"}]});d.expect(b[2]).to.be("target=asPercent(series1%2Cseries2)")}),d.it("should replace target placeholder for hidden series",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"series1",hide:!0},{target:"sumSeries(#A)",hide:!0},{target:"asPercent(#A,#B)"}]});d.expect(b[0]).to.be("target="+encodeURIComponent("asPercent(series1,sumSeries(series1))"))}),d.it("should replace target placeholder when nesting query references",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"series1"},{target:"sumSeries(#A)"},{target:"asPercent(#A,#B)"}]});d.expect(b[2]).to.be("target="+encodeURIComponent("asPercent(series1,sumSeries(series1))"))}),d.it("should fix wrong minute interval parameters",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"summarize(prod.25m.count, '25m', 'sum')"}]});d.expect(b[0]).to.be("target="+encodeURIComponent("summarize(prod.25m.count, '25min', 'sum')"))}),d.it("should fix wrong month interval parameters",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"summarize(prod.5M.count, '5M', 'sum')"}]});d.expect(b[0]).to.be("target="+encodeURIComponent("summarize(prod.5M.count, '5mon', 'sum')"))}),d.it("should ignore empty targets",function(){var b=a.ds.buildGraphiteParams({targets:[{target:"series1"},{target:""}]});d.expect(b.length).to.be(2)})})})});