/*! grafana - v3.0.4 - 2016-06-01
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["test/lib/common","test/specs/helpers","../datasource","../metric_find_query"],function(a){var b,c,d,e;return{setters:[function(a){b=a},function(a){c=a},function(a){d=a},function(a){e=a}],execute:function(){b.describe("PrometheusMetricFindQuery",function(){var a=new c["default"].ServiceTestContext,f={url:"proxied",directUrl:"direct",user:"test",password:"mupp"};b.beforeEach(b.angularMocks.module("grafana.core")),b.beforeEach(b.angularMocks.module("grafana.services")),b.beforeEach(b.angularMocks.inject(function(b,c,e,g){a.$q=b,a.$httpBackend=e,a.$rootScope=c,a.ds=g.instantiate(d.PrometheusDatasource,{instanceSettings:f}),e.when("GET",/\.html$/).respond("")})),b.describe("When performing metricFindQuery",function(){var c,d;b.it("label_values(resource) should generate label search query",function(){d={status:"success",data:["value1","value2","value3"]},a.$httpBackend.expect("GET","proxied/api/v1/label/resource/values").respond(d);var f=new e["default"](a.ds,"label_values(resource)");f.process().then(function(a){c=a}),a.$httpBackend.flush(),a.$rootScope.$apply(),b.expect(c.length).to.be(3)}),b.it("label_values(metric, resource) should generate series query",function(){d={status:"success",data:[{__name__:"metric",resource:"value1"},{__name__:"metric",resource:"value2"},{__name__:"metric",resource:"value3"}]},a.$httpBackend.expect("GET","proxied/api/v1/series?match[]=metric").respond(d);var f=new e["default"](a.ds,"label_values(metric, resource)");f.process().then(function(a){c=a}),a.$httpBackend.flush(),a.$rootScope.$apply(),b.expect(c.length).to.be(3)}),b.it('label_values(metric{label1="foo", label2="bar", label3="baz"}, resource) should generate series query',function(){d={status:"success",data:[{__name__:"metric",resource:"value1"},{__name__:"metric",resource:"value2"},{__name__:"metric",resource:"value3"}]},a.$httpBackend.expect("GET","proxied/api/v1/series?match[]=metric").respond(d);var f=new e["default"](a.ds,"label_values(metric, resource)");f.process().then(function(a){c=a}),a.$httpBackend.flush(),a.$rootScope.$apply(),b.expect(c.length).to.be(3)}),b.it("metrics(metric.*) should generate metric name query",function(){d={status:"success",data:["metric1","metric2","metric3","nomatch"]},a.$httpBackend.expect("GET","proxied/api/v1/label/__name__/values").respond(d);var f=new e["default"](a.ds,"metrics(metric.*)");f.process().then(function(a){c=a}),a.$httpBackend.flush(),a.$rootScope.$apply(),b.expect(c.length).to.be(3)}),b.it("query_result(metric) should generate metric name query",function(){d={status:"success",data:{resultType:"vector",result:[{metric:{__name__:"metric",job:"testjob"},value:[1443454528,"3846"]}]}},a.$httpBackend.expect("GET",/proxied\/api\/v1\/query\?query=metric&time=.*/).respond(d);var f=new e["default"](a.ds,"query_result(metric)");f.process().then(function(a){c=a}),a.$httpBackend.flush(),a.$rootScope.$apply(),b.expect(c.length).to.be(1),b.expect(c[0].text).to.be('metric{job="testjob"} 3846 1443454528000')})})})}}});