mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Add async/await
This commit is contained in:
@@ -3,10 +3,9 @@ jest.mock('app/core/store');
|
||||
|
||||
describe('backend_srv', function() {
|
||||
let _httpBackend = options => {
|
||||
if (options.method === 'GET' && options.url === 'gateway-error') {
|
||||
console.log(options);
|
||||
if (options.url === 'gateway-error') {
|
||||
return Promise.reject({ status: 502 });
|
||||
} else if (options.method === 'POST') {
|
||||
// return Promise.resolve({});
|
||||
}
|
||||
return Promise.resolve({});
|
||||
};
|
||||
@@ -22,17 +21,14 @@ describe('backend_srv', function() {
|
||||
// })
|
||||
// );
|
||||
|
||||
describe('when handling errors', function() {
|
||||
it('should return the http status code', function(done) {
|
||||
describe('when handling errors', () => {
|
||||
it('should return the http status code', async () => {
|
||||
// _httpBackend.whenGET('gateway-error').respond(502);
|
||||
_backendSrv
|
||||
.datasourceRequest({
|
||||
let res = await _backendSrv.datasourceRequest({
|
||||
url: 'gateway-error',
|
||||
})
|
||||
.catch(function(err) {
|
||||
expect(err.status).toBe(502);
|
||||
done();
|
||||
});
|
||||
console.log(res);
|
||||
expect(res.status).toBe(502);
|
||||
// _httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user