review feedback - throw error in smart_callback catch block
This commit is contained in:
parent
17f2ba7fac
commit
970386e603
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
export default class SmartInterval {
|
export default class SmartInterval {
|
||||||
/**
|
/**
|
||||||
* @param { function } opts.callback A Promise, called on each iteration (required) unless still in progress
|
* @param { function } opts.callback Function that returns a promise, called on each iteration unless still in progress (required)
|
||||||
* @param { milliseconds } opts.startingInterval `currentInterval` is set to this initially
|
* @param { milliseconds } opts.startingInterval `currentInterval` is set to this initially
|
||||||
* @param { milliseconds } opts.maxInterval `currentInterval` will be incremented to this
|
* @param { milliseconds } opts.maxInterval `currentInterval` will be incremented to this
|
||||||
* @param { milliseconds } opts.hiddenInterval `currentInterval` is set to this
|
* @param { milliseconds } opts.hiddenInterval `currentInterval` is set to this
|
||||||
|
@ -113,8 +113,9 @@ export default class SmartInterval {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((err) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
throw new Error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,16 +58,19 @@ describe('SmartInterval', function () {
|
||||||
}, DEFAULT_LONG_TIMEOUT);
|
}, DEFAULT_LONG_TIMEOUT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment while waiting for callback', function (done) {
|
it('does not increment while waiting for callback', function () {
|
||||||
|
jasmine.clock().install();
|
||||||
|
|
||||||
const smartInterval = createDefaultSmartInterval({
|
const smartInterval = createDefaultSmartInterval({
|
||||||
callback: () => new Promise($.noop),
|
callback: () => new Promise($.noop),
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
jasmine.clock().tick(DEFAULT_SHORT_TIMEOUT);
|
||||||
|
|
||||||
const oneInterval = smartInterval.cfg.startingInterval * DEFAULT_INCREMENT_FACTOR;
|
const oneInterval = smartInterval.cfg.startingInterval * DEFAULT_INCREMENT_FACTOR;
|
||||||
expect(smartInterval.getCurrentInterval()).toEqual(oneInterval);
|
expect(smartInterval.getCurrentInterval()).toEqual(oneInterval);
|
||||||
done();
|
|
||||||
}, DEFAULT_SHORT_TIMEOUT);
|
jasmine.clock().uninstall();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue