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

System.register(["test/lib/common","app/features/dashboard/import/dash_import","app/core/config"],function(a){var b,c,d;return{setters:[function(a){b=a},function(a){c=a},function(a){d=a}],execute:function(){b.describe("DashImportCtrl",function(){var a={},e={search:b.sinon.stub().returns(Promise.resolve([])),get:b.sinon.stub()};b.beforeEach(b.angularMocks.module("grafana.core")),b.beforeEach(b.angularMocks.inject(function(b,d,f){a.$q=f,a.scope=b.$new(),a.ctrl=d(c.DashImportCtrl,{$scope:a.scope,backendSrv:e})})),b.describe("when uploading json",function(){b.beforeEach(function(){d["default"].datasources={ds:{type:"test-db"}},a.ctrl.onUpload({__inputs:[{name:"ds",pluginId:"test-db",type:"datasource",pluginName:"Test DB"}]})}),b.it("should build input model",function(){b.expect(a.ctrl.inputs.length).to.eql(1),b.expect(a.ctrl.inputs[0].name).to.eql("ds"),b.expect(a.ctrl.inputs[0].info).to.eql("Select a Test DB data source")}),b.it("should set inputValid to false",function(){b.expect(a.ctrl.inputsValid).to.eql(!1)})}),b.describe("when specifing grafana.net url",function(){b.beforeEach(function(){a.ctrl.gnetUrl="http://grafana.net/dashboards/123",e.get=b.sinon.spy(function(){return Promise.resolve({})}),a.ctrl.checkGnetDashboard()}),b.it("should call gnet api with correct dashboard id",function(){b.expect(e.get.getCall(0).args[0]).to.eql("api/gnet/dashboards/123")})}),b.describe("when specifing dashbord id",function(){b.beforeEach(function(){a.ctrl.gnetUrl="2342",e.get=b.sinon.spy(function(){return Promise.resolve({})}),a.ctrl.checkGnetDashboard()}),b.it("should call gnet api with correct dashboard id",function(){b.expect(e.get.getCall(0).args[0]).to.eql("api/gnet/dashboards/2342")})})})}}});