/*! grafana - v1.5.4 - 2014-05-13
 * Copyright (c) 2014 Torkel Ödegaard; Licensed Apache License */

define(["mocks/dashboard-mock","underscore","services/filterSrv"],function(a,b){describe("filterSrv",function(){var c,d;beforeEach(module("kibana.services")),beforeEach(module(function(b){d=a.create(),b.value("dashboard",d)})),beforeEach(inject(function(a){c=a})),describe("init",function(){beforeEach(function(){c.add({name:"test",current:{value:"oogle"}}),c.init()}),it("should initialize template data",function(){var a=c.applyFilterToTarget("this.[[test]].filters");expect(a).to.be("this.oogle.filters")})}),describe("filterOptionSelected",function(){beforeEach(function(){c.add({name:"test"}),c.filterOptionSelected(c.list[0],{value:"muuuu"})}),it("should set current value and update template data",function(){var a=c.applyFilterToTarget("this.[[test]].filters");expect(a).to.be("this.muuuu.filters")})}),describe("timeRange",function(){it("should return unparsed when parse is false",function(){c.setTime({from:"now",to:"now-1h"});var a=c.timeRange(!1);expect(a.from).to.be("now"),expect(a.to).to.be("now-1h")}),it("should return parsed when parse is true",function(){c.setTime({from:"now",to:"now-1h"});var a=c.timeRange(!0);expect(b.isDate(a.from)).to.be(!0),expect(b.isDate(a.to)).to.be(!0)})}),describe("setTime",function(){it("should return disable refresh for absolute times",function(){d.current.refresh=!0,c.setTime({from:"2011-01-01",to:"2015-01-01"}),expect(d.current.refresh).to.be(!1)}),it("should restore refresh after relative time range is set",function(){d.current.refresh=!0,c.setTime({from:"2011-01-01",to:"2015-01-01"}),expect(d.current.refresh).to.be(!1),c.setTime({from:"2011-01-01",to:"now"}),expect(d.current.refresh).to.be(!0)})})})});