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

System.register(["test/lib/common","test/specs/helpers","test/mocks/history-mocks"],function(a,b){"use strict";var c,d,e;b&&b.id;return{setters:[function(a){c=a},function(a){d=a},function(a){e=a}],execute:function(){c.describe("historySrv",function(){var a=new d.default.ServiceTestContext,b=e.versions(),f=e.restore;c.beforeEach(c.angularMocks.module("grafana.core")),c.beforeEach(c.angularMocks.module("grafana.services")),c.beforeEach(c.angularMocks.inject(function(c){a.$httpBackend=c,c.whenRoute("GET","api/dashboards/id/:id/versions").respond(b),c.whenRoute("POST","api/dashboards/id/:id/restore").respond(function(a,b,c,d,e){var g=JSON.parse(c);return[200,f(g.version)]})})),c.beforeEach(a.createService("historySrv")),c.describe("getHistoryList",function(){c.it("should return a versions array for the given dashboard id",function(d){a.service.getHistoryList({id:1}).then(function(a){c.expect(a).to.eql(b),d()}),a.$httpBackend.flush()}),c.it("should return an empty array when not given an id",function(b){a.service.getHistoryList({}).then(function(a){c.expect(a).to.eql([]),b()}),a.$httpBackend.flush()}),c.it("should return an empty array when not given a dashboard",function(b){a.service.getHistoryList().then(function(a){c.expect(a).to.eql([]),b()}),a.$httpBackend.flush()})}),c.describe("restoreDashboard",function(){c.it("should return a success response given valid parameters",function(b){var d=6;a.service.restoreDashboard({id:1},d).then(function(a){c.expect(a).to.eql(f(d)),b()}),a.$httpBackend.flush()}),c.it("should return an empty object when not given an id",function(b){a.service.restoreDashboard({},6).then(function(a){c.expect(a).to.eql({}),b()}),a.$httpBackend.flush()})})})}}});