/*! grafana - v4.5.1 - 2017-09-19
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["test/lib/common","../query_variable"],function(a,b){"use strict";var c,d;b&&b.id;return{setters:[function(a){c=a},function(a){d=a}],execute:function(){c.describe("QueryVariable",function(){c.describe("when creating from model",function(){c.it("should set defaults",function(){var a=new d.QueryVariable({},null,null,null,null,null);c.expect(a.datasource).to.be(null),c.expect(a.refresh).to.be(0),c.expect(a.sort).to.be(0),c.expect(a.name).to.be(""),c.expect(a.hide).to.be(0),c.expect(a.options.length).to.be(0),c.expect(a.multi).to.be(!1),c.expect(a.includeAll).to.be(!1)}),c.it("get model should copy changes back to model",function(){var a=new d.QueryVariable({},null,null,null,null,null);a.options=[{text:"test"}],a.datasource="google",a.regex="asd",a.sort=50;var b=a.getSaveModel();c.expect(b.options.length).to.be(1),c.expect(b.options[0].text).to.be("test"),c.expect(b.datasource).to.be("google"),c.expect(b.regex).to.be("asd"),c.expect(b.sort).to.be(50)}),c.it("if refresh != 0 then remove options in presisted mode",function(){var a=new d.QueryVariable({},null,null,null,null,null);a.options=[{text:"test"}],a.refresh=1;var b=a.getSaveModel();c.expect(b.options.length).to.be(0)})}),c.describe("can convert and sort metric names",function(){var a=new d.QueryVariable({},null,null,null,null,null);a.sort=3,c.describe("can sort a mixed array of metric variables",function(){var b=[{text:"0",value:"0"},{text:"1",value:"1"},{text:null,value:3},{text:void 0,value:4},{text:"5",value:null},{text:"6",value:void 0},{text:null,value:"7"},{text:void 0,value:"8"},{text:9,value:null},{text:10,value:void 0},{text:"",value:void 0},{text:void 0,value:""}],d=a.metricNamesToVariableValues(b);c.it("should return in same order",function(){var a=0;c.expect(d.length).to.be(11),c.expect(d[a++].text).to.be(""),c.expect(d[a++].text).to.be("0"),c.expect(d[a++].text).to.be("1"),c.expect(d[a++].text).to.be("3"),c.expect(d[a++].text).to.be("4"),c.expect(d[a++].text).to.be("5"),c.expect(d[a++].text).to.be("6")})})})})}}});