From 2f6b302375bbe7c562e6df09760f1f4b495b2715 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 27 Jul 2018 15:51:56 +0200 Subject: [PATCH] Test passing. Remove Karma --- public/app/core/specs/backend_srv.jest.ts | 23 +++++----------- public/app/core/specs/backend_srv_specs.ts | 31 ---------------------- 2 files changed, 7 insertions(+), 47 deletions(-) delete mode 100644 public/app/core/specs/backend_srv_specs.ts diff --git a/public/app/core/specs/backend_srv.jest.ts b/public/app/core/specs/backend_srv.jest.ts index 2d62716622a..c65464aa875 100644 --- a/public/app/core/specs/backend_srv.jest.ts +++ b/public/app/core/specs/backend_srv.jest.ts @@ -12,24 +12,15 @@ describe('backend_srv', function() { let _backendSrv = new BackendSrv(_httpBackend, {}, {}, {}, {}); - // beforeEach(angularMocks.module('grafana.core')); - // beforeEach(angularMocks.module('grafana.services')); - // beforeEach( - // angularMocks.inject(function($httpBackend, $http, backendSrv) { - // _httpBackend = $httpBackend; - // _backendSrv = backendSrv; - // }) - // ); - describe('when handling errors', () => { it('should return the http status code', async () => { - // _httpBackend.whenGET('gateway-error').respond(502); - let res = await _backendSrv.datasourceRequest({ - url: 'gateway-error', - }); - console.log(res); - expect(res.status).toBe(502); - // _httpBackend.flush(); + try { + await _backendSrv.datasourceRequest({ + url: 'gateway-error', + }); + } catch (err) { + expect(err.status).toBe(502); + } }); }); }); diff --git a/public/app/core/specs/backend_srv_specs.ts b/public/app/core/specs/backend_srv_specs.ts deleted file mode 100644 index 74b058b98c8..00000000000 --- a/public/app/core/specs/backend_srv_specs.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { describe, beforeEach, it, expect, angularMocks } from 'test/lib/common'; -import 'app/core/services/backend_srv'; - -describe('backend_srv', function() { - var _backendSrv; - var _httpBackend; - - beforeEach(angularMocks.module('grafana.core')); - beforeEach(angularMocks.module('grafana.services')); - beforeEach( - angularMocks.inject(function($httpBackend, $http, backendSrv) { - _httpBackend = $httpBackend; - _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(); - }); - }); -});