Changed code style as to not to disable any eslint rules
This commit is contained in:
parent
20cbfb482b
commit
58f2db49ee
1 changed files with 13 additions and 14 deletions
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable arrow-body-style*/
|
||||
require('~/lib/utils/common_utils');
|
||||
|
||||
(() => {
|
||||
|
@ -168,13 +167,13 @@ require('~/lib/utils/common_utils');
|
|||
describe('gl.utils.backOff', () => {
|
||||
it('solves the promise from the callback', (done) => {
|
||||
const expectedResponseValue = 'Success!';
|
||||
gl.utils.backOff((next, stop) => {
|
||||
return new Promise((resolve) => {
|
||||
gl.utils.backOff((next, stop) => (
|
||||
new Promise((resolve) => {
|
||||
resolve(expectedResponseValue);
|
||||
}).then((resp) => {
|
||||
stop(resp);
|
||||
});
|
||||
}).then((respBackoff) => {
|
||||
})
|
||||
)).then((respBackoff) => {
|
||||
expect(respBackoff).toBe(expectedResponseValue);
|
||||
done();
|
||||
});
|
||||
|
@ -183,7 +182,7 @@ require('~/lib/utils/common_utils');
|
|||
it('catches the rejected promise from the callback ', (done) => {
|
||||
const errorMessage = 'Mistakes were made!';
|
||||
gl.utils.backOff((next, stop) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
new Promise((resolve, reject) => {
|
||||
reject(new Error(errorMessage));
|
||||
}).then((resp) => {
|
||||
stop(resp);
|
||||
|
@ -198,8 +197,8 @@ require('~/lib/utils/common_utils');
|
|||
it('solves the promise correctly after retrying a third time', (done) => {
|
||||
let numberOfCalls = 1;
|
||||
const expectedResponseValue = 'Success!';
|
||||
gl.utils.backOff((next, stop) => {
|
||||
return new Promise((resolve) => {
|
||||
gl.utils.backOff((next, stop) => (
|
||||
new Promise((resolve) => {
|
||||
resolve(expectedResponseValue);
|
||||
}).then((resp) => {
|
||||
if (numberOfCalls < 3) {
|
||||
|
@ -208,8 +207,8 @@ require('~/lib/utils/common_utils');
|
|||
} else {
|
||||
stop(resp);
|
||||
}
|
||||
});
|
||||
}).then((respBackoff) => {
|
||||
})
|
||||
)).then((respBackoff) => {
|
||||
expect(respBackoff).toBe(expectedResponseValue);
|
||||
expect(numberOfCalls).toBe(3);
|
||||
done();
|
||||
|
@ -218,13 +217,13 @@ require('~/lib/utils/common_utils');
|
|||
|
||||
it('rejects the backOff promise after timing out', (done) => {
|
||||
const expectedResponseValue = 'Success!';
|
||||
gl.utils.backOff((next) => {
|
||||
return new Promise((resolve) => {
|
||||
gl.utils.backOff(next => (
|
||||
new Promise((resolve) => {
|
||||
resolve(expectedResponseValue);
|
||||
}).then(() => {
|
||||
setTimeout(next(), 5000); // it will time out
|
||||
});
|
||||
}, 3000).catch((errBackoffResp) => {
|
||||
})
|
||||
), 3000).catch((errBackoffResp) => {
|
||||
expect(errBackoffResp instanceof Error).toBe(true);
|
||||
expect(errBackoffResp.message).toBe('BACKOFF_TIMEOUT');
|
||||
done();
|
||||
|
|
Loading…
Reference in a new issue