mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
26 lines
655 B
TypeScript
26 lines
655 B
TypeScript
import { BackendSrv } from 'app/core/services/backend_srv';
|
|
jest.mock('app/core/store');
|
|
|
|
describe('backend_srv', function() {
|
|
const _httpBackend = options => {
|
|
if (options.url === 'gateway-error') {
|
|
return Promise.reject({ status: 502 });
|
|
}
|
|
return Promise.resolve({});
|
|
};
|
|
|
|
const _backendSrv = new BackendSrv(_httpBackend, {}, {}, {}, {});
|
|
|
|
describe('when handling errors', () => {
|
|
it('should return the http status code', async () => {
|
|
try {
|
|
await _backendSrv.datasourceRequest({
|
|
url: 'gateway-error',
|
|
});
|
|
} catch (err) {
|
|
expect(err.status).toBe(502);
|
|
}
|
|
});
|
|
});
|
|
});
|