/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["test/lib/common","test/specs/helpers","../datasource"],function(a){var b,c,d;return{setters:[function(a){b=a},function(a){c=a},function(a){d=a}],execute:function(){b.describe("opentsdb",function(){var a=new c["default"].ServiceTestContext,e={url:"",jsonData:{tsdbVersion:1}};b.beforeEach(b.angularMocks.module("grafana.core")),b.beforeEach(b.angularMocks.module("grafana.services")),b.beforeEach(a.providePhase(["backendSrv"])),b.beforeEach(b.angularMocks.inject(function(b,c,f,g){a.$q=b,a.$httpBackend=f,a.$rootScope=c,a.ds=g.instantiate(d.OpenTsDatasource,{instanceSettings:e}),f.when("GET",/\.html$/).respond("")})),b.describe("When performing metricFindQuery",function(){var c,d;b.beforeEach(function(){a.backendSrv.datasourceRequest=function(b){return d=b,a.$q.when({data:[{target:"prod1.count",datapoints:[[10,1],[12,1]]}]})}}),b.it("metrics() should generate api suggest query",function(){a.ds.metricFindQuery("metrics(pew)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/suggest"),b.expect(d.params.type).to.be("metrics"),b.expect(d.params.q).to.be("pew")}),b.it("tag_names(cpu) should generate lookup query",function(){a.ds.metricFindQuery("tag_names(cpu)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/search/lookup"),b.expect(d.params.m).to.be("cpu")}),b.it("tag_values(cpu, test) should generate lookup query",function(){a.ds.metricFindQuery("tag_values(cpu, hostname)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/search/lookup"),b.expect(d.params.m).to.be("cpu{hostname=*}")}),b.it("tag_values(cpu, test) should generate lookup query",function(){a.ds.metricFindQuery("tag_values(cpu, hostname, env=$env)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/search/lookup"),b.expect(d.params.m).to.be("cpu{hostname=*,env=$env}")}),b.it("tag_values(cpu, test) should generate lookup query",function(){a.ds.metricFindQuery("tag_values(cpu, hostname, env=$env, region=$region)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/search/lookup"),b.expect(d.params.m).to.be("cpu{hostname=*,env=$env,region=$region}")}),b.it("suggest_tagk() should generate api suggest query",function(){a.ds.metricFindQuery("suggest_tagk(foo)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/suggest"),b.expect(d.params.type).to.be("tagk"),b.expect(d.params.q).to.be("foo")}),b.it("suggest_tagv() should generate api suggest query",function(){a.ds.metricFindQuery("suggest_tagv(bar)").then(function(a){c=a}),a.$rootScope.$apply(),b.expect(d.url).to.be("/api/suggest"),b.expect(d.params.type).to.be("tagv"),b.expect(d.params.q).to.be("bar")})})})}}});