{"size": 851, "ext": "js", "max_stars_repo_path": "public/test/specs/backend_srv-specs.js", "max_stars_repo_name": "woodrow-shen/grafana-upstream", "max_stars_repo_stars_event_min_datetime": "2017-03-23T11:10:15.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-16T16:49:30.000Z", "max_issues_repo_path": "public/test/specs/backend_srv-specs.js", "max_issues_repo_name": "woodrow-shen/grafana-upstream", "max_issues_repo_issues_event_min_datetime": "2017-04-06T22:40:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-24T04:48:04.000Z", "max_forks_repo_path": "public/test/specs/backend_srv-specs.js", "max_forks_repo_name": "woodrow-shen/grafana-upstream", "max_forks_repo_forks_event_min_datetime": "2017-05-02T00:46:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-12T20:29:42.000Z"}
{"max_stars_count": 7, "max_issues_count": 20, "max_forks_count": 4, "avg_line_length": 25.0294117647, "max_line_length": 66, "alphanum_fraction": 0.5945945946}
define([
  'app/core/config',
  'app/core/services/backend_srv'
], function() {
  'use strict';

  describe('backend_srv', function() {
    var _backendSrv;
    var _http;
    var _httpBackend;

    beforeEach(module('grafana.core'));
    beforeEach(module('grafana.services'));
    beforeEach(inject(function ($httpBackend, $http, backendSrv) {
      _httpBackend = $httpBackend;
      _http = $http;
      _backendSrv = backendSrv;
    }));

    describe('when handling errors', function() {
      it('should return the http status code', function(done) {
        _httpBackend.whenGET('gateway-error').respond(502);
        _backendSrv.datasourceRequest({
          url: 'gateway-error'
        }).catch(function(err) {
          expect(err.status).to.be(502);
          done();
        });
        _httpBackend.flush();
      });
    });
  });
});
